public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@bootlin.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 0/2] cmd: auto-complete args starting with a $
Date: Tue, 4 Dec 2018 11:33:13 +0100	[thread overview]
Message-ID: <20181204113313.577178ac@bbrezillon> (raw)
In-Reply-To: <20181204101431.854D4242267@gemini.denx.de>

Hi Wolfgang,

On Tue, 04 Dec 2018 11:14:31 +0100
Wolfgang Denk <wd@denx.de> wrote:

> Dear Boris,
> 
> In message <20181204105448.63b9af8c@bbrezillon> you wrote:
> >  
> > > > It's pretty common to pass arguments that start with a $ and are then
> > > > expanded by the shell, and I'm this kind of lazy guy that hits tab all
> > > > the time and expects the shell to suggest something appropriate. So
> > > > here is a patchset adding support for ${} auto-completion and using the
> > > > new helper from the mtd command.    
> > > 
> > > You mean, this feature depends on MTD support?  this is not goot.  
> >
> > Not at all, MTD is just the first user of this dollar_complete()
> > helper. That's what I meant.  
> 
> But is this not based on the code of mtd_name_complete() which is
> only availabole when MTD is present?

Nope. See patch 1, the code is completely independent from the mtd cmd.

> 
> > > Also, you should make this feature configurable.  Not everybody may
> > > want to use it or may have the memory available.  
> >
> > It already depends on CONFIG_AUTO_COMPLETE, and each command has to
> > explicitly call the helper to support ${} auto-completion. Not that $
> > auto-completion only makes sense for some arguments, not all of them.
> > It's the responsibility of the command itself to decide when it should
> > be used.  
> 
> Um... this is not hat I would expect - if we implement
> auto-completion for variables, it should IMO work similar to what a
> standard shell is doing.
> 
> In Bash, I can do:
> 
> -> foo=1234
> -> echo $f<TAB>  
> $f     $flag  $foo

And that's pretty much how it works except that right now, echo has to
be patched to support $ auto-completion.

> -> echo $f  

For the record, not all shell configs expand $foo, some require that foo
be enclosed in ${} (${foo}), that's why the current proposal always
auto-completes $ as ${.

> 
> i. e. this is a feature of the shell and not of any command.
> Implementing this a zillion times for each of the commands in
> inacceptable.  Also, implementing it for one command and not for
> another makese no sense - that would violate the Principle of Least
> Surprise, as you have something which looks convenient but does not
> work everywhere.

Okay, I understand. I can try to hook that up at the common/command.c
level.

> 
> > > Technically - should autocompletion not be prevented for escaped
> > > '$' characters, i. e. hitting TAB after a '\$' sequence should NOT
> > > expand?  
> >
> > It's already the case. The argument has to start with $ or ${ to be
> > auto-completed.  
> 
> We should implement this such that behaviour is similar to what we
> see on a standard shell.

Apart from the "make that available to everyone" comment, is there
anything else you think should be changed? IOW, what is not compliant
with a standard shell auto-completion in my proposal?

Regards,

Boris

  reply	other threads:[~2018-12-04 10:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-03 22:07 [U-Boot] [PATCH 0/2] cmd: auto-complete args starting with a $ Boris Brezillon
2018-12-03 22:07 ` [U-Boot] [PATCH 1/2] common: command: Provide a dollar_complete() helper Boris Brezillon
2018-12-03 22:07 ` [U-Boot] [PATCH 2/2] cmd: mtd: auto-complete args starting with a $ when appropriate Boris Brezillon
2018-12-04  9:44 ` [U-Boot] [PATCH 0/2] cmd: auto-complete args starting with a $ Wolfgang Denk
2018-12-04  9:54   ` Boris Brezillon
2018-12-04 10:14     ` Wolfgang Denk
2018-12-04 10:33       ` Boris Brezillon [this message]
2018-12-04 13:00         ` Wolfgang Denk
2018-12-04 13:11           ` Boris Brezillon
2018-12-04 13:54         ` Boris Brezillon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181204113313.577178ac@bbrezillon \
    --to=boris.brezillon@bootlin.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox