From: Wolfgang Denk Date: Tue, 04 Dec 2018 11:14:31 +0100 Subject: [U-Boot] [PATCH 0/2] cmd: auto-complete args starting with a $ In-Reply-To: <20181204105448.63b9af8c@bbrezillon> References: <20181203220726.19370-1-boris.brezillon@bootlin.com> <20181204094419.6907C242267@gemini.denx.de> <20181204105448.63b9af8c@bbrezillon> Message-ID: <20181204101431.854D4242267@gemini.denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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? > > 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 $f $flag $foo -> echo $f 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. > > 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. Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de What we hope ever to do with ease, we must learn first to do with diligence. - Samuel Johnson