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: Eduardo A . Bustamante López
Subject: Re: ls doesn't work in if statements in bash 4.3
Date: Thu, 27 Mar 2014 09:59:44 -0700
User-agent: Mutt/1.5.21 (2010-09-15)

> These restrictions that you talk about are important, but you don't seem to 
> hear me when I say "My filenames never have spaces".  My directories never 
> have spaces.  I am meticulous about my filesystems.  On one hand I realize 
> you think you're being helpful to someone who has just started bash 
> programming, but since I've been at this for > 12 years it has gotten a 
> little condescending.  I solved the issue myself about 10 minutes later.  I 
> thought it was interesting that with the problematic dir_colors file I was 
> unable to use 'ls' but 'find' worked.  I work as a system administrator so I 
> understand that people are at different levels in terms of technical 
> knowledge.  It's all about reading comprehension.  If you had read "My 
> filenames never have spaces" part and actually paid attention you would see 
> that the problem had nothing to do with spaces.  But no.  Everyone wants to 
> show how smart they are that spaces can mess things up.  Wow!  Thanks!  My 
> guess is that you'll breeze right past this post and continue to give me 
> helpful hints.  Thanks guys!
> 
> --Snarky System Administrator (Is there any other kind?)
Who are you replying to? Since you do not address a specific person,
or at least keep part of the email you're replying to.

And I read the whole thread, and the only thing you mention is:

> I have a script which goes out and converts all my filenames (/home/user/) 
> with 
> spaces into filenames with underscores.  I also convert them to lower case.  

Well, that's cool. But spaces are not the only characters that break
that for loop. But, OK, lets pretend your environment is perfect,
that your filenames don't have spaces, tabs, newlines, asterisks,
question marks, and so on.

Even with all this in mind, don't rely on word splitting. There's a
simpler, easier to read way of doing it, which is: let the shell
expand the globs!


And this whole thread is just ironic. You're defending that your
approach is right, but using that same flawed approach caused you
this issue in the first place! (the dir_colors issue most likely
caused terminal sequences to be captured by `...`, messing with your
filenames).



Anyways. Documented behavior, so, no bash bug. Try to use help-bash
next time though, for scripting issues (that aren't bash bugs). Also,
I recommend you to use 'set -x' more often, it's awesome to catch
these types of bugs caused by non-graphic stuff.

-- 
Eduardo Alan Bustamante López



reply via email to

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