From 7cfd8be0dc83342b4a71f3a8e5b7efab4670e50c Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Tue, 25 Sep 2007 22:29:00 +0800 Subject: [EXPAND] Move parse-time quote flag detection to run-time Because the parser does not recursively parse parameter expansion with respect to quotes, we can't accurately determine quote status at parse time. This patch works around this by moving the quote detection to run-time where we do interpret it recursively. Test case: foo=\\ echo "<${foo#[\\]}>" Old result: <\> New result: <> --- src/TOUR | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/TOUR') diff --git a/src/TOUR b/src/TOUR index 0c60e2a..4baac62 100644 --- a/src/TOUR +++ b/src/TOUR @@ -159,7 +159,6 @@ special codes defined in parser.h. The special codes are: CTLVAR Variable substitution CTLENDVAR End of variable substitution CTLBACKQ Command substitution - CTLBACKQ|CTLQUOTE Command substitution inside double quotes CTLESC Escape next character A variable substitution contains the following elements: @@ -179,16 +178,13 @@ stitution. The possible types are: VSASSIGN ${var=text} VSASSIGN|VSNUL ${var=text} -In addition, the type field will have the VSQUOTE flag set if the -variable is enclosed in double quotes. The name of the variable -comes next, terminated by an equals sign. If the type is not -VSNORMAL, then the text field in the substitution follows, ter- -minated by a CTLENDVAR byte. +The name of the variable comes next, terminated by an equals +sign. If the type is not VSNORMAL, then the text field in the +substitution follows, terminated by a CTLENDVAR byte. Commands in back quotes are parsed and stored in a linked list. The locations of these commands in the string are indicated by -CTLBACKQ and CTLBACKQ+CTLQUOTE characters, depending upon whether -the back quotes were enclosed in double quotes. +the CTLBACKQ character. The character CTLESC escapes the next character, so that in case any of the CTL characters mentioned above appear in the input, -- cgit 1.4.1