Skip to content

Instantly share code, notes, and snippets.

@plaster
Last active November 15, 2016 03:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save plaster/7778901274652e5e37076b268c698584 to your computer and use it in GitHub Desktop.
Save plaster/7778901274652e5e37076b268c698584 to your computer and use it in GitHub Desktop.
testtestb.sh, testtest_{3,4}.txt: Thanks to @hio
if test $1 = $2; then echo '='; else echo '!='; fi
if test "$1" = "$2"; then echo '='; else echo '!='; fi
if [ $1 = $2 ]; then echo '='; else echo '!='; fi
if [ "$1" = "$2" ]; then echo '='; else echo '!='; fi
% for VAR_SH in dash bash zsh; do $VAR_SH testtest.sh '!' '!'; $VAR_SH testtest.sh -a -a; $VAR_SH testtest.sh; done
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
% for VAR_SH in dash bash zsh; do $VAR_SH testtest.sh '!' '-z'; $VAR_SH testtest.sh -z -o; $VAR_SH testtest.sh '!'; done
!=
!=
!=
!=
!=
!=
!=
!=
!=
!=
!=
!=
!=
!=
!=
!=
!=
!=
!=
!=
!=
!=
!=
!=
!=
!=
!=
!=
!=
!=
!=
!=
!=
!=
!=
!=
% for VAR_SH in dash bash zsh; do $VAR_SH testtestb.sh '*'; done
testtestb.sh: 1: testtestb.sh: [[: not found
!=
testtestb.sh: 2: testtestb.sh: [[: not found
!=
!=
!=
!=
!=
% zsh -x testtest.sh 'x'
+/etc/zsh/zshenv:15> [[ -z /usr/local/bin:/usr/bin:/bin:/usr/games || /usr/local/bin:/usr/bin:/bin:/usr/games == /bin:/usr/bin ]]
+testtest.sh:1> test x '='
testtest.sh:1: parse error: condition expected: x
+testtest.sh:1> echo '!='
!=
+testtest.sh:2> test x '=' ''
+testtest.sh:2> echo '!='
!=
+testtest.sh:3> [ x '=' ']'
testtest.sh:3: parse error: condition expected: x
+testtest.sh:3> echo '!='
!=
+testtest.sh:4> [ x '=' '' ']'
+testtest.sh:4> echo '!='
!=
% for VAR_SH in dash bash zsh; do $VAR_SH testtestb.sh '*'; done
testtestb.sh: 1: testtestb.sh: [[: not found
!=
testtestb.sh: 2: testtestb.sh: [[: not found
!=
!=
!=
!=
!=
% for VAR_SH in dash bash zsh; do $VAR_SH testtestx.sh '*'; done
!=
!=
!=
% zsh -x testtestb.sh 'x'
+/etc/zsh/zshenv:15> [[ -z /usr/local/bin:/usr/bin:/bin:/usr/games || /usr/local/bin:/usr/bin:/bin:/usr/games == /bin:/usr/bin ]]
+testtestb.sh:1> [[ x == ]]
+testtestb.sh:1> echo '!='
!=
+testtestb.sh:2> [[ x == ]]
+testtestb.sh:2> echo '!='
!=
% zsh -x testtestx.sh 'x'
+/etc/zsh/zshenv:15> [[ -z /usr/local/bin:/usr/bin:/bin:/usr/games || /usr/local/bin:/usr/bin:/bin:/usr/games == /bin:/usr/bin ]]
+testtestx.sh:1> test Xx '=' X
+testtestx.sh:1> echo '!='
!=
if [[ $1 = $2 ]]; then echo '='; else echo '!='; fi
if [[ "$1" = "$2" ]]; then echo '='; else echo '!='; fi
if test "X$1" = "X$2"; then echo '='; else echo '!='; fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment