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