Re: For Loops and Space in Names

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

 



On 09Dec2008 18:24, RGH <rgheck@xxxxxxxxxxx> wrote:
> Since we were talking here about this last week, I thought I'd mention this:
>     
> http://www.cyberciti.biz/tips/handling-filenames-with-spaces-in-bash.html
> Most of the ideas there are ones that got mentioned here, but there is a  
> new one.

If you mean this:

  # a backspace/newline pair without resorting to cumbersome echo
  IFS='^H
  '
  FILES=foo/*
  for f in $FILES
  do

That's awful!

This:

  for f in foo/*
  do

is totally reliable and does not need $IFS hacking (which amounts to
"guess a char I might not see in a filename).

And don't get me started on the evils of using $UPPER_CASE variable names
for script local variables. The $UPPER_CASE names ae routines exported
($PATH, $PS1, $MANPATH, etc etc); lower case is where your locals should
go. (Remember, you will never know the full list of exported variables,
and if you reuse one that is already in the environment then you've just
broken it for every subprogram you call.)

Cheers,
-- 
Cameron Simpson <cs@xxxxxxxxxx> DoD#743
http://www.cskk.ezoshosting.com/cs/

Network Planning Constraint Of The Month:
        You can't send bits over a non-existant link.
                - Valdis Kletnieks <valdis@xxxxxxxxxxxxxxx>

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines

[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux