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


Groups > gnu.bash.bug > #14815 > unrolled thread

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

Started byIlkka Virta <itvirta@iki.fi>
First post2018-11-13 19:54 +0200
Last post2018-11-13 19:54 +0200
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

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

FromIlkka Virta <itvirta@iki.fi>
Date2018-11-13 19:54 +0200
SubjectRe: built-in '[' and '/usr/bin/[' yield different results
Message-ID<mailman.3987.1542131708.1284.bug-bash@gnu.org>
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

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web