colis-anr / morbig

A static parser for POSIX Shell
Other
190 stars 8 forks source link

Will backslash be removed as a quote character? #110

Open limjcst opened 5 years ago

limjcst commented 5 years ago

Below is a test case, which is thought good https://github.com/colis-anr/morbig/blob/2441635d3836135294a2d5c2d89f149f09c368b4/tests/good/2.6-word-expansions/2.6.3-command-substitutions/backslash-in-nested-subshells.sh#L3

Its corresponding expected CST, inside WordDoubleQuoted, is https://github.com/colis-anr/morbig/blob/2441635d3836135294a2d5c2d89f149f09c368b4/tests/good/2.6-word-expansions/2.6.3-command-substitutions/backslash-in-nested-subshells.sh.expected#L41

where \\\", printed as \", is exactly the content of echo "\"". However, in bash(version 4.3.48), the output of echo "\"" is just ".

As mentioned in IEEE Std 1003.1™ - 2017, Vol. 3: Shell and Utilities, Issue 7, (Is it out of date?)

2.6.7 Quote Removal
    The quote characters (<backslash>, single-quote, and double-quote) that were present in the
    original word shall be removed unless they have themselves been quoted.

Is \<backslash> removal under plan, or left to the conversion stage from concrete syntax tree to abstract syntax tree?

BTW, thanks for your brilliant work!