From owner-freebsd-questions@FreeBSD.ORG Mon Jan 12 02:08:22 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 4C7C51065677 for ; Mon, 12 Jan 2009 02:08:22 +0000 (UTC) (envelope-from jeffrey@goldmark.org) Received: from out1.smtp.messagingengine.com (out1.smtp.messagingengine.com [66.111.4.25]) by mx1.freebsd.org (Postfix) with ESMTP id 24C7E8FC17 for ; Mon, 12 Jan 2009 02:08:21 +0000 (UTC) (envelope-from jeffrey@goldmark.org) Received: from compute1.internal (compute1.internal [10.202.2.41]) by out1.messagingengine.com (Postfix) with ESMTP id 19FE920F9F5 for ; Sun, 11 Jan 2009 21:08:21 -0500 (EST) Received: from heartbeat2.messagingengine.com ([10.202.2.161]) by compute1.internal (MEProxy); Sun, 11 Jan 2009 21:08:21 -0500 X-Sasl-enc: 112OxHS3HI18GyKuGxP0iyGjaPtKUULsKQn8z2gCg844 1231726100 Received: from hagrid.ewd.goldmark.org (n114.ewd.goldmark.org [72.64.118.114]) by mail.messagingengine.com (Postfix) with ESMTPSA id CB70C48C00 for ; Sun, 11 Jan 2009 21:08:20 -0500 (EST) Message-Id: <7740275E-77AA-45C1-B95E-C1F62D2AAB29@goldmark.org> From: Jeffrey Goldberg To: "mail.list freebsd-questions" Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v930.3) Date: Sun, 11 Jan 2009 20:08:18 -0600 X-Mailer: Apple Mail (2.930.3) Subject: bash versus sh test builtin 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: Mon, 12 Jan 2009 02:08:22 -0000 The -ne operator for [ in /bin/sh doesn't seem to work as in bash. Also the bash behavior here is what matches /bin/[ most closely. $ /bin/sh $ if [ $UID -ne 0 ] ; then > echo not root > fi [: -ne: unexpected operator $ exit $ echo $SHELL /usr/local/bin/bash [jeffrey@dobby ~/src/mount-rsnap]$ if [ $UID -ne 0 ] ; then > echo not root > fi not root Does anyone have a recommendation of how to run this simple test in / bin/sh and how to write tests reasonably portably? -j -- Jeffrey Goldberg http://www.goldmark.org/jeff/