From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rasmus Villemoes Date: Fri, 25 Sep 2020 13:19:39 +0200 Subject: [PATCH 0/3] add "call" command Message-ID: <20200925111942.4629-1-rasmus.villemoes@prevas.dk> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de This adds a way to call a "function" defined in the environment with arguments. I.e., whereas run foo requires one to set the (shell or environment) variables referenced from foo beforehand, with this one can instead do call 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. As I write in patch 2, it should be possible to get rid of the "call" and simply allow foo arg1 arg2 arg3 i.e. if the search for a command named foo fails, try an environment variable by that name and do it as "call". But that change of behaviour, I think, requires a separate opt-in config knob, and can be done later if someone actually wants that. Rasmus Villemoes (3): cli_hush.c: refactor handle_dollar() to prepare for cmd_call cli_hush.c: add "call" command ut: add small hush tests cmd/Kconfig | 8 ++++ common/cli_hush.c | 93 +++++++++++++++++++++++++++++++++---- configs/sandbox64_defconfig | 1 + configs/sandbox_defconfig | 1 + include/test/suites.h | 1 + test/cmd/Makefile | 1 + test/cmd/hush.c | 90 +++++++++++++++++++++++++++++++++++ test/cmd_ut.c | 6 +++ 8 files changed, 191 insertions(+), 10 deletions(-) create mode 100644 test/cmd/hush.c -- 2.23.0