bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Parse error in case command


From: Roman Rakus
Subject: Parse error in case command
Date: Thu, 03 Mar 2011 19:35:20 +0100
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Thunderbird/3.1.7

case x"" in.. is falsely parsed. See the example:
$ cat test.sh
case x"" in

  x?) printf "unexpected\n"
     ;;
  x) printf "expected\n"
     ;;
  *) printf "no match\n"
     ;;
esac
$ ./bash ./test.sh
unexpected
$ ./bash --version
GNU bash, version 4.2.6(1)-release (x86_64-unknown-linux-gnu)

x"" is parsed to "x\177" and the \177 is not removed. I'm not sure about the right fix. In bash version 4.1.7(1)-release it is parsed to not ending \177. I see the difference in expand_word_internal() function. In the bash 4.2 there is;
          /* We do not want to add quoted nulls to strings that are only
             partially quoted; we can throw them away. */
if (temp == 0 && quoted_state == PARTIALLY_QUOTED && (word->flags & (W_NOSPLIT|W_NOSPLIT2)))
            continue;
where in bash 4.1 there isn't test for word flags. So in bash 4.2 the if statement is false and CTLNUL is added to resulting string, but not in bash 4.1. I guess there are two possible solutions - Don't add CTLNUL or remove it after.

RR



reply via email to

[Prev in Thread] Current Thread [Next in Thread]