[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: |
Mike Frysinger |
Subject: |
Re: ls doesn't work in if statements in bash 4.3 |
Date: |
Wed, 26 Mar 2014 21:15:22 -0400 |
User-agent: |
KMail/4.12.3 (Linux/3.13.0; KDE/4.12.3; x86_64; ; ) |
On Wed 26 Mar 2014 17:45:33 address@hidden wrote:
> I thought about the changes I have made recently and I had added the
> following into my .bashrc:
>
> eval $(dircolors -b ~/.dir_colors)
>
> I commented it out, and now everything works. I think it's still a bug,
> though I know how to fix it.
doubtful the problem is bash. if ls is writing control codes, then bash will
treat them as part of the filename. you can verify by piping the output
through hexdump and seeing what shows up.
this is a good example though of why using `ls` is almost always the wrong
answer. use unadorned globs:
for f in dog*; do ...
i'd point out that if any of the files in your dir have whitespace, your code
would also break:
touch 'dog a b c'
for f in `ls dog*`; do ...
-mike
signature.asc
Description: This is a digitally signed message part.
- ls doesn't work in if statements in bash 4.3, billycongo, 2014/03/26
- Re: ls doesn't work in if statements in bash 4.3, billycongo, 2014/03/26
- Re: ls doesn't work in if statements in bash 4.3,
Mike Frysinger <=
- Re: ls doesn't work in if statements in bash 4.3, Eduardo A . Bustamante López, 2014/03/27
- Re: ls doesn't work in if statements in bash 4.3, billycongo, 2014/03/27
- Re: ls doesn't work in if statements in bash 4.3, Greg Wooledge, 2014/03/27
- easier construction of arrays, Mike Frysinger, 2014/03/27
- Re: easier construction of arrays, Pierre Gaston, 2014/03/27
- Re: easier construction of arrays, Dan Douglas, 2014/03/27
- Re: easier construction of arrays, Mike Frysinger, 2014/03/27
- Re: easier construction of arrays, Dan Douglas, 2014/03/27
Re: ls doesn't work in if statements in bash 4.3, billycongo, 2014/03/27
Re: ls doesn't work in if statements in bash 4.3, billycongo, 2014/03/27