From 4ce809e7d469b9b398c37bba4cff44e5b7975c1e Mon Sep 17 00:00:00 2001 From: Ville Juven Date: Tue, 4 Apr 2023 13:42:59 +0300 Subject: [PATCH] nsh/nsh_parse: Fix handling of back-quotes The logic that handles back-quotes was faulty, i.e. example command set FOO `ls -l` would be split into two tokens as follows: - set FOO `ls - -l` This results in nsh: `: no matching ` error, this fixes that issue. --- nshlib/nsh_parse.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/nshlib/nsh_parse.c b/nshlib/nsh_parse.c index 800daf08c..cf8310bd7 100644 --- a/nshlib/nsh_parse.c +++ b/nshlib/nsh_parse.c @@ -1826,7 +1826,13 @@ static FAR char *nsh_argument(FAR struct nsh_vtbl_s *vtbl, /* Is it a back-quote ? These are not removed here */ - if (*pend != '`') + if (*pend == '`') + { + /* Yes, keep the quotes in place */ + + pend = qend; + } + else { /* No, get rid of the single / double quotes here */