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]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux