Date: Thu, 3 Sep 2009 00:14:00 -0500 From: Dan Nelson <dnelson@allantgroup.com> To: jerry M <jerrry94087@yahoo.com> Cc: freebsd-questions@freebsd.org Subject: Re: Why /bin/sh doesn't like the line: if test "x$my_var" == "xyes"; then Message-ID: <20090903051400.GG2855@dan.emsphone.com> In-Reply-To: <423199.64505.qm@web110716.mail.gq1.yahoo.com> References: <423199.64505.qm@web110716.mail.gq1.yahoo.com>
next in thread | previous in thread | raw e-mail | index | archive | help
In the last episode (Sep 03), jerry M said: > configure file got this line and it causes the message: test: xyes: > unexpected operator But removing spaces around == or replacing == with = > makes it to work. > > On Linux though this line works fine. > > Why spaces around == would cause failure? What is the version of /bin/sh > currently used in 7.2? Where is it taken from? --version, -v, -version > don't ever print version I guess due to FreeBSD policy of not versioning > individual utilities. == isn't a valid comparison operator for the test command. See the FreeBSD manpage, or the Posix docs: http://www.opengroup.org/onlinepubs/9699919799/toc.htm. You need to use =. Certain Linux distributions use bash as /bin/sh, which shortcuts the test command internally and allows bash extensions, even in bourne-shell mode. Debian and Ubuntu use dash instead of bash, and this script would fail on them as well. -- Dan Nelson dnelson@allantgroup.com
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090903051400.GG2855>