From 4786efaff071d5c57060f172db0ef519e23d4366 Mon Sep 17 00:00:00 2001 From: ishaangandhi Date: Fri, 9 Oct 2020 11:45:51 -0400 Subject: [PATCH] Remove double quotation from parameter --- src/prelexer.mll | 1 - src/prelexerState.ml | 4 +- .../basic.sh.expected | 94 +------ .../operator-in-parameter.sh.expected | 11 +- .../recursive.sh.expected | 73 +++--- .../vicious.sh.expected | 229 +++--------------- .../with-spaces.sh.expected | 102 +------- ...-following-variable-parameters.sh.expected | 130 +--------- 8 files changed, 96 insertions(+), 548 deletions(-) diff --git a/src/prelexer.mll b/src/prelexer.mll index 04637f48..d584e03d 100644 --- a/src/prelexer.mll +++ b/src/prelexer.mll @@ -479,7 +479,6 @@ rule token current = parse | "}" { debug ~rule:"parameter-closing-brace" lexbuf current; if under_braces current then - let current = pop_quotation OpeningBrace current in let _ = debug ~rule:"parameter-closing-brace-after-pop" lexbuf current in return lexbuf current [] else diff --git a/src/prelexerState.ml b/src/prelexerState.ml index ea494387..3ad2ba50 100644 --- a/src/prelexerState.ml +++ b/src/prelexerState.ml @@ -25,7 +25,7 @@ type atom = | QuotingMark of quote_kind | AssignmentMark -and quote_kind = SingleQuote | DoubleQuote | OpeningBrace +and quote_kind = SingleQuote | DoubleQuote module AtomBuffer : sig type t @@ -265,13 +265,11 @@ let pop_quotation k b = match k with | SingleQuote -> WordSingleQuoted word | DoubleQuote -> WordDoubleQuoted word - | OpeningBrace -> WordDoubleQuoted word in let squote = match k with | SingleQuote -> "'" ^ squote ^ "'" | DoubleQuote -> "\"" ^ squote ^ "\"" - | OpeningBrace -> squote in let quote = WordComponent (squote, quoted_word) in let buffer = AtomBuffer.make (quote :: buffer) in diff --git a/tests/good/2.6-word-expansions/2.6.2-parameter-expansion/basic.sh.expected b/tests/good/2.6-word-expansions/2.6.2-parameter-expansion/basic.sh.expected index 687db644..f928960c 100644 --- a/tests/good/2.6-word-expansions/2.6.2-parameter-expansion/basic.sh.expected +++ b/tests/good/2.6-word-expansions/2.6.2-parameter-expansion/basic.sh.expected @@ -48,20 +48,7 @@ [ "Word", "word", - [ - [ - "WordDoubleQuoted", - [ - "Word", - "word", - [ - [ - "WordLiteral", "word" - ] - ] - ] - ] - ] + [ [ "WordLiteral", "word" ] ] ] ] ] @@ -109,18 +96,7 @@ [ "Word", "word", - [ - [ - "WordDoubleQuoted", - [ - "Word", - "word", - [ - [ "WordLiteral", "word" ] - ] - ] - ] - ] + [ [ "WordLiteral", "word" ] ] ] ] ] @@ -168,16 +144,7 @@ [ "Word", "word", - [ - [ - "WordDoubleQuoted", - [ - "Word", - "word", - [ [ "WordLiteral", "word" ] ] - ] - ] - ] + [ [ "WordLiteral", "word" ] ] ] ] ] @@ -225,16 +192,7 @@ [ "Word", "word", - [ - [ - "WordDoubleQuoted", - [ - "Word", - "word", - [ [ "WordLiteral", "word" ] ] - ] - ] - ] + [ [ "WordLiteral", "word" ] ] ] ] ] @@ -282,16 +240,7 @@ [ "Word", "word", - [ - [ - "WordDoubleQuoted", - [ - "Word", - "word", - [ [ "WordLiteral", "word" ] ] - ] - ] - ] + [ [ "WordLiteral", "word" ] ] ] ] ] @@ -339,16 +288,7 @@ [ "Word", "word", - [ - [ - "WordDoubleQuoted", - [ - "Word", - "word", - [ [ "WordLiteral", "word" ] ] - ] - ] - ] + [ [ "WordLiteral", "word" ] ] ] ] ] @@ -396,16 +336,7 @@ [ "Word", "word", - [ - [ - "WordDoubleQuoted", - [ - "Word", - "word", - [ [ "WordLiteral", "word" ] ] - ] - ] - ] + [ [ "WordLiteral", "word" ] ] ] ] ] @@ -453,16 +384,7 @@ [ "Word", "word", - [ - [ - "WordDoubleQuoted", - [ - "Word", - "word", - [ [ "WordLiteral", "word" ] ] - ] - ] - ] + [ [ "WordLiteral", "word" ] ] ] ] ] diff --git a/tests/good/2.6-word-expansions/2.6.2-parameter-expansion/operator-in-parameter.sh.expected b/tests/good/2.6-word-expansions/2.6.2-parameter-expansion/operator-in-parameter.sh.expected index 8f791cfa..42b42ff3 100644 --- a/tests/good/2.6-word-expansions/2.6.2-parameter-expansion/operator-in-parameter.sh.expected +++ b/tests/good/2.6-word-expansions/2.6.2-parameter-expansion/operator-in-parameter.sh.expected @@ -41,16 +41,7 @@ [ "Word", "<