From owner-freebsd-questions@FreeBSD.ORG Thu Sep 3 05:14:02 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 402961065672 for ; Thu, 3 Sep 2009 05:14:02 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: from email2.allantgroup.com (email2.emsphone.com [199.67.51.116]) by mx1.freebsd.org (Postfix) with ESMTP id 04E5C8FC17 for ; Thu, 3 Sep 2009 05:14:01 +0000 (UTC) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by email2.allantgroup.com (8.14.0/8.14.0) with ESMTP id n835E1lp089456 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 3 Sep 2009 00:14:01 -0500 (CDT) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (smmsp@localhost [127.0.0.1]) by dan.emsphone.com (8.14.3/8.14.3) with ESMTP id n835E0Zl022400 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 3 Sep 2009 00:14:00 -0500 (CDT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.14.3/8.14.3/Submit) id n835E0YX022398; Thu, 3 Sep 2009 00:14:00 -0500 (CDT) (envelope-from dan) Date: Thu, 3 Sep 2009 00:14:00 -0500 From: Dan Nelson To: jerry M Message-ID: <20090903051400.GG2855@dan.emsphone.com> References: <423199.64505.qm@web110716.mail.gq1.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <423199.64505.qm@web110716.mail.gq1.yahoo.com> X-OS: FreeBSD 7.2-STABLE User-Agent: Mutt/1.5.19 (2009-01-05) X-Virus-Scanned: ClamAV version 0.94.2, clamav-milter version 0.94.2 on email2.allantgroup.com X-Virus-Status: Clean X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0.2 (email2.allantgroup.com [199.67.51.78]); Thu, 03 Sep 2009 00:14:01 -0500 (CDT) X-Scanned-By: MIMEDefang 2.45 Cc: freebsd-questions@freebsd.org Subject: Re: Why /bin/sh doesn't like the line: if test "x$my_var" == "xyes"; then X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Sep 2009 05:14:02 -0000 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