mbox series

[v2,0/3] allow positional arguments with "run"

Message ID 20201007072052.28200-1-rasmus.villemoes@prevas.dk
Headers show
Series allow positional arguments with "run" | expand

Message

Rasmus Villemoes Oct. 7, 2020, 7:20 a.m. UTC
This enables one to use positional arguments $1..$9 in functions
defined in the environment, rather than having to use global
variables. I.e., whereas

  run foo

requires one to set the (shell or environment) variables referenced
from foo beforehand, with this one can instead do

  run foo -- arg1 arg2 arg3

and use $1... up to $9 in the definition of foo. $# is set so foo can
make decisions based on that, and ${3:-default} works as expected.

In v2, at Heinrich's suggestion, make this available as an extension
of the existing run command rather than being a separate 'call'
command.

Rasmus Villemoes (3):
  cli_hush.c: refactor handle_dollar() to prepare for "run with
    arguments"
  allow positional arguments with "run" command
  ut: add small hush tests

 cmd/Kconfig                 | 10 ++++
 cmd/nvedit.c                |  7 ++-
 common/cli.c                | 44 +++++++++++++++---
 common/cli_hush.c           | 50 ++++++++++++++++----
 configs/sandbox64_defconfig |  1 +
 configs/sandbox_defconfig   |  1 +
 include/cli_hush.h          |  9 ++++
 include/test/suites.h       |  1 +
 test/cmd/Makefile           |  1 +
 test/cmd/hush.c             | 91 +++++++++++++++++++++++++++++++++++++
 test/cmd_ut.c               |  6 +++
 11 files changed, 204 insertions(+), 17 deletions(-)
 create mode 100644 test/cmd/hush.c

Comments

Rasmus Villemoes Nov. 5, 2020, 7:25 a.m. UTC | #1
On 07/10/2020 09.20, Rasmus Villemoes wrote:
> This enables one to use positional arguments $1..$9 in functions
> defined in the environment, 

Tom, can I ask for a decision on these? I know Wolfgang is opposed, and
if that counts as a veto, fine, I'd just like to know so these are at
least not kept hanging indefinitely.

Thanks,
Rasmus
Tom Rini Nov. 6, 2020, 8:52 p.m. UTC | #2
On Thu, Nov 05, 2020 at 08:25:31AM +0100, Rasmus Villemoes wrote:
> On 07/10/2020 09.20, Rasmus Villemoes wrote:
> > This enables one to use positional arguments $1..$9 in functions
> > defined in the environment, 
> 
> Tom, can I ask for a decision on these? I know Wolfgang is opposed, and
> if that counts as a veto, fine, I'd just like to know so these are at
> least not kept hanging indefinitely.

Sorry for the lack of feedback.  I guess, I just don't know.  There's at
least two series now (this and Simon's setexp) where part of the
feedback has been "our hush is ancient, and we should replace and keep
it in sync, and add features _upstream_".  That position isn't wrong.
But it's not easy to do, either.  I know you already said you didn't
have time and wouldn't step up to do that.
Wolfgang Denk Nov. 8, 2020, 1:28 p.m. UTC | #3
Dear Tom,

In message <20201106205245.GH5340@bill-the-cat> you wrote:
> 
> Sorry for the lack of feedback.  I guess, I just don't know.  There's at
> least two series now (this and Simon's setexp) where part of the
> feedback has been "our hush is ancient, and we should replace and keep
> it in sync, and add features _upstream_".  That position isn't wrong.
> But it's not easy to do, either.  I know you already said you didn't
> have time and wouldn't step up to do that.

This argument is not new, and I can fully understand this position,
too.  I'mm all to often myself in the position where the right Thing
(TM) requires more efforts and/or time than what is available in the
given project.

And from the maintainer's point of view, this has always been the
argument to sneak in code which is a workaround at best, and which
itself cements the original problem even more and makes it more
difficult to solve it at the roots.

Best regards,

Wolfgang Denk