From: emrefan on 9 Feb 2010 23:20 Can anybody tell me the difference between the two sciptlets (assuming the shell is korn shell) below: scriplet 1: [[ -f somefile-that-surely-exists && ! otherfile -ot otherfile ]] && echo expected behavior scriplet 2: if [[ -f somefile-that-surely-exists ]]; then if [[ ! otherfile -ot otherfile ]]; then echo expected behavior fi fi I thought since the same file was compared by the "-ot" operator, the expression "! otherfile -ot otherfile" was sure to return true, so I expected to see "expected behavior" with scriptlet 1. Not so. Scriptlet 2 worked as expected. But, can anybody explain why?
From: Icarus Sparry on 9 Feb 2010 23:29 On Tue, 09 Feb 2010 20:20:47 -0800, emrefan wrote: > Can anybody tell me the difference between the two sciptlets (assuming > the shell is korn shell) below: > > scriplet 1: > > [[ -f somefile-that-surely-exists && ! otherfile -ot otherfile ]] && > echo expected behavior > > scriplet 2: > > if [[ -f somefile-that-surely-exists ]]; then > if [[ ! otherfile -ot otherfile ]]; then > echo expected behavior > fi > fi > > I thought since the same file was compared by the "-ot" operator, the > expression "! otherfile -ot otherfile" was sure to return true, so I > expected to see "expected behavior" with scriptlet 1. Not so. Scriptlet > 2 worked as expected. But, can anybody explain why? Scriptlet 1 works for me ( /etc/password exists here). $ [[ -f /etc/passwd && ! /etc/passwd -ot /etc/passwd ]] && echo good good $ echo ${.sh.version} Version JM 93t+ 2009-05-01
|
Pages: 1 Prev: find command: why doesn't this work? Next: Aliasing cd to a function under ksh88 |