Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #14815

Re: built-in '[' and '/usr/bin/[' yield different results

Path csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail
From Ilkka Virta <itvirta@iki.fi>
Newsgroups gnu.bash.bug
Subject Re: built-in '[' and '/usr/bin/[' yield different results
Date Tue, 13 Nov 2018 19:54:28 +0200
Lines 36
Approved bug-bash@gnu.org
Message-ID <mailman.3987.1542131708.1284.bug-bash@gnu.org> (permalink)
References <5b86cf1c-d39a-befc-9734-5be8abd5cddd@heinzerling.com>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding quoted-printable
X-Trace usenet.stanford.edu 1542131709 11875 208.118.235.17 (13 Nov 2018 17:55:09 GMT)
X-Complaints-To action@cs.stanford.edu
To Service <service@heinzerling.com>, bug-bash@gnu.org
Envelope-to bug-bash@gnu.org
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:52.0) Gecko/20100101 Thunderbird/52.9.1
In-Reply-To <5b86cf1c-d39a-befc-9734-5be8abd5cddd@heinzerling.com>
Content-Language en-US
X-SASI-RCODE 200
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; h=subject:to:references:from:message-id:date:mime-version:in-reply-to:content-type:content-transfer-encoding; s=smtp; bh=1b/8XSpovJO8gvBUAWlRnmbuHEjAdt1QnzC3h2RCOhs=; b=TlYurk1CN2O9QFL4IMWu+rNYiF/s8kwNUwjzFFuc+tM8BEgqaqmK33Adr+dYbnzh5lQUosg/P5LMZ66QSbIyxlUTVSAkJKbdCqnf0D8g/avbLcXBIKXonXPH59VJrLgZ8Hny8jjY0Lm1GD5KlhToBhCVwpUzJaEtF+jXxXA6uU9gubQNXrTyis0y1YB+JDSQ7CgrwpXtEPjMtXr0Was35/mwCROoBmaUFY4TlCq1kEIqfZzbZaWDFoGd80T5G7ZD5fkRmw5Sw0ESn1LZQwwc2nuCA2ZSJ9ZpGMsJhkr1tL4HXia6pQ/cXPxhuTertM/UcHcxAmY4IoQG2GgJ2gjroQ==
X-detected-operating-system by eggs.gnu.org: FreeBSD 8.x
X-Received-From 157.24.2.104
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.21
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <http://lists.gnu.org/archive/html/bug-bash/>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
Xref csiph.com gnu.bash.bug:14815

Show key headers only | View raw


On 13.11. 18:29, Service wrote:
>      # Put the above commands into a script, say check.sh
>      # Run with: /bin/sh < check.sh
>      # Or      : /bin/sh ./check.sh
>      # Or      : /usr/bin/env ./check.sh
> 
>      # Output is always not ok:
>      not_nt
>      nt

  $ cat check.sh
  export PATH=""
  /bin/touch file1
  /bin/rm -f file2
  if          [ file1 -nt file2 ]; then echo nt; else echo not_nt; fi
  if /usr/bin/[ file1 -nt file2 ]; then echo nt; else echo not_nt; fi

  $ bash ./check.sh
  nt
  nt

  $ /bin/sh ./check.sh
  not_nt
  nt

Isn't that Windows Linux thingy based on Ubuntu? /bin/sh isn't Bash by 
default on Debian and Ubuntu, so it might be you're just not running the 
script with Bash.


-- 
Ilkka Virta / itvirta@iki.fi

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Re: built-in '[' and '/usr/bin/[' yield different results Ilkka Virta <itvirta@iki.fi> - 2018-11-13 19:54 +0200

csiph-web