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

Rasmus Villemoes
2020-10-07T07:20:49Z

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

--
2.23.0