I need to invoke a custom URL for a macOS GUI app from a terminal (shell) command.
I also need to be able to pass arguments to the URL's query section.
It might look like this:
path=/Volumes/MyDisk
what="some text"
open fafapp://find?loc=$path&inp=$what
The problem is that I need to URL-encode path
and what
first. How can I accomplish this with built-in commands? It should not be necessary to install extra tools for this and should work on macOS 10.11 and later.
I'd also like it consise. It's for instructions to other (non-Terminal-savvy) users for invoking the app via a short shell script, e.g. from automation tools.
Thus, lengthy bash scripts that convert the strings "by hand" are not really a good result for me. Ideally, the open
command would be a one-liner.