Created
September 10, 2012 06:34
-
-
Save blueberrystream/3689251 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
hoge="#" | |
if [ $hoge!="#" ]; then | |
echo "hoge is not # (1st)" | |
fi | |
if [ "$hoge " != "# " ]; then | |
echo "hoge is not # (2nd)" | |
fi | |
# ダブルクォートで囲むだけでいいんじゃねーのって話 | |
if [ "$hoge" != "#" ]; then | |
echo "hoge is not # (3rd)" | |
fi |
さっきのコメなし。
GNU bash, version 3.00.16(1)-release (i386-pc-solaris2.10) だと
hoge is not # (1st)
とだけ表示される。
GNU bash, version 4.1.5(1)-release (x86_64-pc-linux-gnu)でも同じ結果らしい。どうにもbashが != の比較なのに文字列としての比較じゃないことをしてるらしいとかなんとか。
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
GNU bash, version 3.00.16(1)-release (i386-pc-solaris2.10) だと true って表示される。