bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Ilkka Virta
Subject: Re: built-in '[' and '/usr/bin/[' yield different results
Date: Tue, 13 Nov 2018 19:54:28 +0200
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:52.0) Gecko/20100101 Thunderbird/52.9.1

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]