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

From Ilkka Virta <itvirta@iki.fi>
Newsgroups gnu.bash.bug
Subject Re: built-in '[' and '/usr/bin/[' yield different results
Date 2018-11-13 19:54 +0200
Message-ID <mailman.3987.1542131708.1284.bug-bash@gnu.org> (permalink)
References <5b86cf1c-d39a-befc-9734-5be8abd5cddd@heinzerling.com>

Show all headers | 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