Skip to main content
3 of 7
added 22 characters in body
cuonglm
  • 158.2k
  • 41
  • 342
  • 420

It's meaningless.

That's probably a bug with ksh93, if there're too many arguments for a unary operator and the unary operator start with -, then the second one will pick as the argument and the rest will be ignored:

$ ksh -c '[ -f a.out foo bar ] && echo yes' yes $ ksh -c '[ -e a.out foo a ] && echo yes' yes 

Checking the source of test confirm that behavior.

Also doing strace:

$ { strace -p "$$" & sleep 1; [ -f a.out -size +0 ]; kill "$!"; } [1] 18467 Process 18455 attached restart_syscall(<... resuming interrupted call ...>) = 0 stat(".", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 stat("a.out", {st_mode=S_IFREG|0755, st_size=8320, ...}) = 0 kill(18467, SIGTERMProcess 18455 detached <detached ...> 

if you want to check whether a file exist and have size greater than 0, then standard shells have -s test operator:

[ -s file ] && echo 'file exist and size greater than 0' 

ksh88 seems to have the same bug. With my Solaris 10 VM:

$ ksh -c '[ -f a.out foo bar ] && echo yes' yes $ strings /usr/bin/ksh | grep -i version @(#)Version M-11/16/88i 
cuonglm
  • 158.2k
  • 41
  • 342
  • 420