@grainloom my hot take: if you need the short opts to keep your shell one-liners readable to you, don't write them as shell one-liners, and instead write a bit more in python or something so you can use variable names
@bonzoesc i'm confuse, you can use variables in shells too....
(shoutout to rc for having saner variable expansion rules than sh)
@grainloom oh yeah, totally! but most of the time when i get to the point where i want to turn a one-liner into a script, i usually get to choose the language, and i like ruby more than bash
I don't think it would matter much if the way to look up an option wasn't grepping in a man page. The shell should be an IDE that gives you contextual help and autocompletion.
@freakazoid idk, Zsh has pretty good completion, much better even than any "proper" language I've used
manpage browsing is not that bad in acme, it is much MUCH worse if you only have a single ssh connection to a machine and no terminal multiplexing, so you gotta switch back and forth between man and the script/shell
@freakazoid afaik Fish is even better with this stuff but Zsh is good enough for my Linux system administration needs
Some tools, on some shells, will give hints about args in response to tab complete. I wish (1) this was more common, (2) it was using the same system as command-line help, and (3) it integrated with man pages so you could open up a man page without losing your place in a long under-construction shell one-liner and filter it to only the options relevant to what you're using.
@enkiv2 there are argument parsers that also integrate with shell completion. I use http://hackage.haskell.org/package/optparse-applicative
@grainloom but, thanks to history, most… many… some shortopts are POSIX compliant, while most long-opts are not
@grainloom Reminds me of
> command subcommand /argument:value [path.to.file] name.ext;version
Where commands are move, copy, directory, etc. and may be shortened, unless ambiguous, to e.g. dir.
@grainloom That's how I wrote every shell script at every job I had :
- never rely on parameters orders, instead use long options
- avoid defaults
- print full help on any invalid invocation
I don't know if it's The Right Way, but it sure made my coworkers happy.
@grainloom Yeah, there's a few universal short options that are fine, but for 90% of CLI options, they need a long version.
Universal input options I can think of off the top of my head:
-i for input
-o for output
-a for all
-s for silent
-v for verbose
Unless I'm missing any, these are the only acceptable shortcodes that don't need a long version.
Counter-take, if folks wrote good completion scripts for their apps then it wouldn't matter.
@grainloom it'd be a pain if I had to spell out
ssh --proxy-jump host1 host2
every time, instead of
ssh -J host1 host2
@Wolf480pl what about abstracting it a bit? if you need shorthands, just wrap the executable?
yknow, the same way how modules abstract over / combine other modules
@Wolf480pl but imho there should be a builtin way for executables to complete their arguments, which would make this quicker
@grainloom To be fair, today I came across a PowerShell command with the option -VirtualMachineMigrationAuthenticationType which... is great for script readability, but would be a nightmare to type on a console. So that is one reason I appreciate that most bash commands have short options, though long options are also a must. People should have, uh, options 😅
@kazooboy that is going a bit too far, something like -auth-type would suffice for that
but better integrated auto-completion could help with both, i've heard others before suggest executables should be able to give hints to shells about autocompletion, and I think that's something worth checking out.
Cybrespace is an instance of Mastodon, a social network based on open web protocols and free, open-source software. It is decentralized like e-mail.