2 ms·
> For example, would you prefer a “find” command that uses environment variables instead of command line options? I use 'find' so much that my muscle memory wo
by chriswarbo 6y ago
> For example, would you prefer a “find” command that uses environment variables instead of command line options?
I use 'find' so much that my muscle memory would hurt if it changed, but it's actually a really interesting example. Its use of arguments to build a domain-specific language is a cool hack, but pretty horrendous; e.g.
find . -type f -a -not \( -name \*.htm -o -name \*.html \)
We can compare this to tools like 'jq', which use a DSL but keep it inside a single string argument:
key=foo val=bar jq -n '{(env.key): env.val}'
Note that 'jq' also accepts key/value pairs via commandline arguments, but that requires triplets of arguments, e.g.
jq -n --arg key foo --arg val bar '{(env.key): env.val}'
- pklo 6y agoThe second example didn't work for jq-1.6 ---I had to write it as jq -n --arg key foo --arg val bar '{($key): $val}'
- chriswarbo 6y agoYes you're right. I spotted it myself, but only after I couldn't edit anymore :(