I'm trying to set up a shell script to execute on a hotkey. I want the script to take the text
xattr -cr "Applications/[appNameVar].app" in a shell script. I am currently executing it via the terminal for testing purposes, so I can see what is happening.
I am using the quotes around the path name, so any spaces that might in the name of a given app will be escaped in the shell command or in the terminal. When I manually type into the terminal, for instance,
xattr -cr "/Applications/Default Name.app", the terminal correctly interprets the command, escaping the space in the path name, and executing
xattr -cr upon the whole file path.
However, when I have Keyboard Maestro insert the text either via typing or pasting, and then run it (keystroke "Return"), the terminal reads the path name as two separate file paths, namely
I have tried using double quotes (") and single quotes ('), but neither work.
I have tried making just the app name the variable with the rest plain text, and I have tried making the whole text string into a variable. Neither helps.
When I prompt for input, of an App Name, and enter
Default\ Name, using a forward slash to escape the space, the forward slash makes it through to the inserted text in the terminal and the space is escaped correctly, causing the terminal command to execute correctly.
This won't help in the final version of this macro, however, because the final version will be setting a variable as the current front app's path, and there will be no opportunity for a forward slash to be added in before any spaces in the app name.
So, long story short, what is the correct way to pass through the quotes so the full app path is taken in by terminal as one value? Either there's a bug causing it to not work correctly, or there's a correct way to do this and my inexperience is preventing me from finding it.