bug-bash
[Top][All Lists]
Advanced

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

Re: ls doesn't work in if statements in bash 4.3


From: billycongo
Subject: Re: ls doesn't work in if statements in bash 4.3
Date: Thu, 27 Mar 2014 11:58:06 -0700 (PDT)
User-agent: G2/1.0

On Thursday, March 27, 2014 2:15:22 PM UTC-4, Eduardo A. Bustamante López wrote:
> > Your response is "I recommend you to use 'set -x'"?  Nice.  Unfortunately 
> > it also means you're a troll, so further discussion with you is pointless.
> 
> >   
> 
> 
> 
> Well, care to explain why I'm labeled as a troll?
> 
> 
> 
> 
> 
> I ran the following:
> 
> 
> 
>   | bash-4.3$ mkdir a b c
> 
>   | bash-4.3$ touch 1 2 3
> 
>   | bash-4.3$ (set -x; echo '===1'; for file in `ls --color=never`; do [ -e 
> "$file" ] && echo "$file"; done; echo '===2'; for file in `ls 
> --color=always`; do [ -e "$file" ] && echo "$file"; done;)
> 
>   | + echo ===1
> 
>   | ===1
> 
>   | ++ ls --color=never
> 
>   | + for file in '`ls --color=never`'
> 
>   | + '[' -e 1 ']'
> 
>   | + echo 1
> 
>   | 1
> 
>   | + for file in '`ls --color=never`'
> 
>   | + '[' -e 2 ']'
> 
>   | + echo 2
> 
>   | 2
> 
>   | + for file in '`ls --color=never`'
> 
>   | + '[' -e 3 ']'
> 
>   | + echo 3
> 
>   | 3
> 
>   | + for file in '`ls --color=never`'
> 
>   | + '[' -e a ']'
> 
>   | + echo a
> 
>   | a
> 
>   | + for file in '`ls --color=never`'
> 
>   | + '[' -e b ']'
> 
>   | + echo b
> 
>   | b
> 
>   | + for file in '`ls --color=never`'
> 
>   | + '[' -e c ']'
> 
>   | + echo c
> 
>   | c
> 
>   | + echo ===2
> 
>   | ===2
> 
>   | ++ ls --color=always
> 
>   | + for file in '`ls --color=always`'
> 
>   | + '[' -e 1 ']'
> 
>   | + echo 1
> 
>   | 1
> 
>   | + for file in '`ls --color=always`'
> 
>   | + '[' -e 2 ']'
> 
>   | + echo 2
> 
>   | 2
> 
>   | + for file in '`ls --color=always`'
> 
>   | + '[' -e 3 ']'
> 
>   | + echo 3
> 
>   | 3
> 
>   | + for file in '`ls --color=always`'
> 
>   | + '[' -e 'a' ']'
> 
>   | + for file in '`ls --color=always`'
> 
>   | + '[' -e 'b' ']'
> 
>   | + for file in '`ls --color=always`'
> 
>   | + '[' -e 'c' ']'
> 
> 
> 
> 
> 
> Due to limitations on what can be sent by email, you won't be able to
> 
> notice that the last three entries are shown in color. But running
> 
> this on a terminal will make that evident quickly. And this would've
> 
> hinted you immediately what the issue was.
> 
> 
> 
> (but hey, I'm a troll ;) )
> 
> 
> 
> 
> 
> 
> 
> 
> 
> ---
> 
> Also, on a slightly different issue, please... really, please, use
> 
> Google Groups properly. It's VERY annoying to have to skip through
> 
> pages of text just to see your 1 line reply. Also, it appears as if
> 
> you're replying to yourself. This makes it hard to know who you're
> 
> talking to.
> 
> 
> 
> Follow the suggestions here to make the experience less painful to us
> 
> who have to read you: https://wiki.python.org/moin/GoogleGroupsPython
> 
> 
> 
> -- 
> 
> Eduardo Alan Bustamante López

That actually did fix the issue.  Instead of:

for f in `ls *.mp3`

I used

for f in `/bin/ls *.mp3`

but your example

for file in '`ls --color=never`'

is good.

So there are some issues with ls and color.  This I think is interesting.  Not 
sure whether it qualifies as a bug.  

I should not have given up on you.  I was also wrong in my usage of the reply 
function.  

There were communication issues.  Your behaviour was similar to a troll.  Why 
would you tell me "set -x" when I mentioned that I have done shell programming  
for > 12 years?  Why would you ignore the fact that I told you I am meticulous 
with my environment?  What a troll does is deliberately misread information so 
that they can tell you things that you already know.  A troll never admits that 
they are wrong, and they tell you that you are doing things wrong.

You know that there are a million ways to program.  It's part of the beauty.  I 
maintain all the scripts at work, but I never tell people how to program.  If 
it works, then that's good. I love keeping an environment with perfect 
directories and filenames.  I don't do it so I can do sloppy programming.  I 
love shell programming because it's quick and dirty.  I also program in perl, 
awk, expect, python, and ruby.  

It's a matter of respect.  I tend to err on the side of talking above people's 
level rather than talk down to them.  Just try to think how you would respond 
if someone told you to use 'set -x'.

I do appreciate your help.  As long as I've been at it I never bothered with 
colors.  It's just so fascinating that it could have this effect.



reply via email to

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