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

Re: ${(z)} split of unmatched, doubled ((



On Sep 27, 11:51pm, Daniel Shahaf wrote:
} Subject: Re: ${(z)} split of unmatched, doubled ((
}
} Since the "two subshells" case can be disambiguated by adding a space,
} but arithmetic evluations cannot be disambiguated, I assume ambiguous
} cases should be resolved in favour of the latter.
} 
} I see the problem: ${(z)} is bufferwords(), which calls ctxtlex(), which
} ultimately calls cmd_or_math(), which classifies the unbalanced opening
} parentheses as a syntax error, because they have no matching ')' before
} the end of the input.  Consequently, cmd_or_math() returns CMD_OR_MATH_ERR
} on line 512 (in the 'if (lexstop)' block), which causes ctxtlex() to
} return LEXERR.

So perhaps this:

diff --git a/Src/lex.c b/Src/lex.c
index 70f3d14..6eb3c82 100644
--- a/Src/lex.c
+++ b/Src/lex.c
@@ -785,6 +785,8 @@ gettok(void)
 		    return INPAR;
 
 		default:
+		    if (lexflags & LEXFLAGS_ACTIVE)
+			tokstr = dyncat("((", tokstr);
 		    return LEXERR;
 		}
 	    }

It might be prudent to also test that tokstr != NULL there, but I have
not found a sample input where that occurs.



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