On 21/10/15 13:56, Eric Blake wrote:
> On the libvirt list, the question was raised on what happens if you have
> a long command line, but then forget the arguments of an option that
> requires an argument, so you try to add --help in-place to learn them.
> For example:
> 
> $ ls --block-size --help
> ls: invalid --block-size argument '--help'
> 
> Okay, this makes sense, '--help' is appearing in the argument position,
> not as an option, so it got eaten by --block-size, and we don't get
> help.  So let's try again, by placing a filler for the option argument,
> then our real --help attempt; and since --help is idempotent, it doesn't
> matter how often it appears up front, so let's use --help as the filler:

At this stage it might be a simpler thought process
for users to just `ls --help` rather than expecting
adding another --help to work.  Also the typing it saves
is the command name vs {Up}, i.e. not much.

I'd be 60:40 against complicating the commands for that.

As for alternatives, you could:

  !!:0 --help

Or setup and alias to do that:

  alias lh='`history -p \!\!:0 --help`'

New users could use the standard: command --help,
while power users saving time could do the above.

This also works with bash >= 4.4 which now supports --help.

Also relate would be integrating `explain¹` functionality
into the man page system or whatever,
with associated shortcut alias or in .inputrc to access that.

  alias ex='`explain history -p \!\!`'

That would have the advantage of narrowing the explanation
to the options used.

thanks,
Pádraig.

¹ https://www.mankier.com/blog/explaining-shell-commands-in-the-shell.html

Reply via email to