I found this bug when I tried a tiny script which checks a directory is empty 
or not.

 [ "$(ls -A ./dir)" ] && echo "Not Empty" || echo "Empty"

After `mkdir ./dir' and without adding anything into ./dir, run the script, the 
echoed message is "Empty". But when adding the `--color' option to `ls',


 [ "$(ls -A --color ./dir)" ] && echo "Not Empty" || echo "Empty"
 
the echoed message is always "Not Empty", regardless of the fact that ./dir is 
actually EMPTY. Below is the tested result.


day[~]$ mkdir dir
day[~]$ ls -l dir
total 0

day[~]$ [ "$(ls -A ./dir)" ] && echo "Not Empty" || echo "Empty"
Empty
day[~]$ [ "$(ls -A -F --color ./dir)" ] && echo "Not Empty" || echo "Empty"
Not Empty
day[~]$ [ "$(ls -A -F ./dir)" ] && echo "Not Empty" || echo "Empty"
Empty
day[~]$ [ "$(ls -A --color ./dir)" ] && echo "Not Empty" || echo "Empty"
Not Empty

Version Info:
ls (GNU coreutils) 6.9
GNU bash, version 3.1.17(2)-release

Linux zenwalk 2.6.23.12 #1 SMP PREEMPT Wed Dec 19 14:34:44 CET 2007 i686 AMD 
Turion(tm) 64 X2 AuthenticAMD GNU/Linux

PS: I have also tested on Ubuntu 7.10, the same result. So I think it's a 
common bug. 



--

DAY's
dAi Yi

_______________________________________________
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to