I have what I think is a fairly simple macro: It prompts for user input, then executes a shell script using some boilerplate text plus the variable set in the user input. (I’m writing this to simplify setting hidden prefs for one of our own apps, which I do a lot when testing.)
The Prompt for Input bit saves the input to a variable named witchPref. The next command executes a shell script, combining the variable with some fixed text:
Execute text script:
defaults write /Users/me/Library/Application\ Support/Witch/Settings $KMVAR_witchPref
So far so good … I’ve confirmed that the output string is the correct format (by temporarily saving it to variable via “Set variable to text,” then using the same line as above). I can take the output string, paste it in Terminal, and it works.
But it will not work in a shell script action, and I know the problem is quotes. I just don’t know how to fix it. Here’s a typical variable I need to pass to the shell:
“Selection Style” -int 0
So the full command is:
defaults write /Users/me/Library/Application\ Support/Witch/Settings “Selection Style” -int 0
If I paste that in Terminal, it works. If I paste the stored string from the variable I create, it works. But in a shell script action, I get this:
Could not parse: Style". Try single-quoting it.
So I do, changing the " to ’ … then I get this:
Unexpected argument -int; leaving defaults unchanged.
So I thought I’d try outsmarting it. I changed the pasted text to…
Selection\ Style\ -int\ 0
And my shell script action to …
defaults write /Users/robg/Library/Application\ Support/Witch/Settings “$KMVAR_witchPref”
But that got me …
Rep argument is not a dictionary. Defaults have not been changed.
Argh … can someone explain what obvious thing I’m overlooking here?