Open a URL with parameterized query arguments (URL-encode) 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=&quot;some text&quot;
open fafapp://find?loc=$path&amp;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 &quot;by hand&quot; are not really a good result for me. Ideally, the open command would be a one-liner.
You have lots of requirements, which makes for a slightly convoluted solution:
open fafapp://find?loc=$(python -c &quot;import urllib, sys; print urllib.quote(sys.argv[1])&quot; &quot;$path&quot;)&amp;inp=$(python -c &quot;import urllib, sys; print urllib.quote(sys.argv[1])&quot; &quot;$what&quot;)

This uses python, which is pre-installed on macOS 10.11 and later (including Big Sur). It is also a one-liner (although a long one).