Yea, that'd be tough! As I was intrigued by this, and had no clue what the issue was, I went searching for an answer. And I found one (an explanation, that is), and a fix that works perfectly, but the data source is one that isn't necessarily well received here, so I'll leave them anonymous for now. But they said this:
The issue arises because Keyboard Maestro's shell script action processes each variable as a separate entity and does not interpret the pipe (
|
) character as a command separator when it's part of a single variable. Instead, it treats the entire value of the variable as a single command argument, which is why it fails.
ㅤ
To address this, you can use theeval
command in your shell script action to force the shell to interpret the contents of the variable as a command.
And indeed, that is the solution—this works perfectly with the last part of your complex example:
I never would have thought to try eval
on my own, and my source's interpretation of the cause of the problem makes sense to me. But as with all answers, please evaluate against your own sources for confirmation. But eval
definitely makes it work :).
-rob.