- Get path of Finder item
- Save path to variable
$KMVAR_to execute shell script with variable as argument
wc -l $KMVAR_MyFile
(where the variable
MyFile is set to
So far, so good. But if the path has a space or weird character in it, I need to be able to quote the path. If I were doing this outside of Keyboard Maestro, I would do it like this:
wc -l '/Users/jack/my file with spaces.csv'
If I run that exact line of code in a shell script action within Keyboard Maestro—no variable—it works fine. But when I try to use a variable, it fails. In fact, it fails:
- If I don't quote the path
- If I quote it before saving it to a KM variable
- If I quote the actual
$KMVAR…text inside the shell script
How do I pass a path string through a KM variable to a shell when the path string has spaces?
P.S. I assume I could regex out all offending characters to make the path shell-friendly, but that seems like a hack. I'm guessing that's not the "right" way to solve this problem.
Line Count - 3 Test.kmmacros (2.4 KB)