How do I deal with spaces in pathnames when sharing variables to bash?

This is the variable output when the target path is /Users/will/Dropbox/the zettelkasten. I've tried single and double quoting and substituting the space between the and zettelkasten with a %20, but nothing helps. Do I have to remove the space in the $KMVAR_zettelkastenDirectory used in my bash script?

As an afterthought, might there be an easier way of dealing with this?

Output of the tmp variable.

/var/folders/p2/rqq4bs5555l3w0264l1wkkgw0000gn/T/Keyboard-Maestro-Script-7192AB26-61CC-4CE2-924A-1E863B14A830: line 1: cd: "/Users/will/Dropbox/the: No such file or directory
Applications
Library
System
Users
Volumes

I suppose I should test my ideas before I reply, but have you tried putting double quotes either in the first action or the second action? My guess is that either will solve your problem.

Yes, should work with something like:

cd "$KMVAR_zettelkastenDirectory"

I think.

That did it. Putting the double quotes in the script instead of the Keyboard Maestro variable was key.

Thanks to both of you.

You are right. It will only work in the second action.

Quotes in shell scripts can get very complicated. This was an easy case, and I still wasn't 100% right.