Skip to content

Instantly share code, notes, and snippets.

@ingydotnet
Created January 13, 2016 17:01
Show Gist options
  • Save ingydotnet/cbcac5bb4c1886fb9606 to your computer and use it in GitHub Desktop.
Save ingydotnet/cbcac5bb4c1886fb9606 to your computer and use it in GitHub Desktop.
Bash bug wrt `[[` and quoting?
$ x='a\b'
$ echo $x
a\b
$ echo "$x"
a\b
$ echo $x | hexdump -C
00000000 61 5c 62 0a |a\b.|
00000004
$ [ $x == $x ] || echo hmmm
$ [ "$x" == "$x" ] || echo hmmm
$ [[ $x == $x ]] || echo hmmm
hmmm
$ [[ "$x" == "$x" ]] || echo hmmm
$ [[ $x == "$x" ]] || echo hmmm
$ [[ "$x" == $x ]] || echo hmmm
hmmm
$
@ingydotnet
Copy link
Author

Tested on:

Darwin -- GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin15)
Linux -- GNU bash, version 4.3.11(1)-release
MINGW64_NT-6.2 -- GNU bash, version 4.3.42(5)-release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment