The DEL ($'\177') character does not behave like the other control characters when used with the regex operator inside the test keyword.
This example shows the difference in operation: ubuntu@ubuntu:~$ for c in $'\001' $'\a' $'\177' $'\377'; do for r in "$c" "\\$c" "\\[$c]"; do [[ $c =~ $r ]]; printf '[[ %q =~ %q ]] -> %d\n' "$c" "$r" "$?"; done; printf %s\\n ---; done; [[ $'\001' =~ $'\001' ]] -> 0 [[ $'\001' =~ $'\\\001' ]] -> 0 [[ $'\001' =~ $'\\[\001]' ]] -> 1 --- [[ $'\a' =~ $'\a' ]] -> 0 [[ $'\a' =~ $'\\\a' ]] -> 0 [[ $'\a' =~ $'\\[\a]' ]] -> 1 --- [[ $'\177' =~ $'\177' ]] -> 0 [[ $'\177' =~ $'\\\177' ]] -> 1 [[ $'\177' =~ $'\\[\177]' ]] -> 1 --- [[ $'\377' =~ $'\377' ]] -> 0 [[ $'\377' =~ $'\\\377' ]] -> 0 [[ $'\377' =~ $'\\[\377]' ]] -> 1 --- Notice that only $'\177' seems to fail in the middle case, while the others work just fine. I also noticed the following strange behavior in bash under Cygwin: $ for c in $'\001' $'\a' $'\177' $'\377'; do for r in "$c" "\\$c" "\\[$c]"; do [[ $c =~ $r ]]; printf '[[ %q =~ %q ]] -> %d\n' "$c" "$r" "$?"; done; printf %s\\n ---; done; [[ $'\001' =~ $'\001' ]] -> 0 [[ $'\001' =~ $'\\\001' ]] -> 0 [[ $'\001' =~ $'\\[\001]' ]] -> 1 --- [[ $'\a' =~ $'\a' ]] -> 0 [[ $'\a' =~ $'\\\a' ]] -> 0 [[ $'\a' =~ $'\\[\a]' ]] -> 1 --- [[ $'\177' =~ $'\177' ]] -> 0 [[ $'\177' =~ $'\\\177' ]] -> 1 [[ $'\177' =~ $'\\[\177]' ]] -> 1 --- [[ $'\377' =~ $'\377' ]] -> 2 [[ $'\377' =~ $'\\\377' ]] -> 2 [[ $'\377' =~ $'\\[\377]' ]] -> 2 --- Notice the weird return code for non-ASCII characters. I wonder if this has to do more with the regex library it was compiled against. The bash versions: - cygwin: $ bash --version GNU bash, version 4.1.10(4)-release (i686-pc-cygwin) - ubuntu: $ bash --version GNU bash, version 4.2.25(1)-release (x86_64-pc-linux-gnu) (seems to be present in 4.3.x, the DEL character issue) Why is DEL treated specially when preceded by a backslash in the regex operator? -- Eduardo Alan Bustamante López