Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [BUG] (z)-flag interrupts if $() in input



On Sun, 30 Oct 2016 15:25:25 +0000
Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
> Should the command
> .
>     % echo foo $() bar
> .
> print "foo bar\n" or return a parse error?
> 

That's obviously a bug.  The fix is easy, although I don't know why the
case of end of input in a normal input sequence, just above, needs to be
different.

pws

diff --git a/Src/parse.c b/Src/parse.c
index 24b8cd9..50a0d5f 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -594,7 +594,7 @@ par_event(int endtok)
     if (tok == ENDINPUT)
 	return 0;
     if (tok == endtok)
-	return 0;
+	return 1;
 
     p = ecadd(0);
 
diff --git a/Test/D08cmdsubst.ztst b/Test/D08cmdsubst.ztst
index 89e7259..3625373 100644
--- a/Test/D08cmdsubst.ztst
+++ b/Test/D08cmdsubst.ztst
@@ -153,3 +153,17 @@
   eval 'foo echo this just works, OK\?)'
 0:backtracking within command string parsing with alias still pending
 >this just works, OK?
+
+  (
+    set errexit
+    show_nargs() { print $#; }
+    print a $() b
+    print c "$()" d
+  )
+0:Empty $() is a valid empty substitution.
+>a b
+>c  d
+
+  empty=$() && print "'$empty'"
+0:Empty $() is a valid assignment
+>''



Messages sorted by: Reverse Date, Date, Thread, Author