OK, I think I got something that works.  The $IFS seems to control bash's
definition of whitespace.  If you change it to include only tabs and
newlines,

IFS=$(echo -e \\t)

then for loops won't separate filenames with spaces into separate
objects.  Meaning, you can run

for I in `cat playlist.m3u`; ...

without problems. You may, however, wish to set this back after you're
done; it may (probably will) cause problems later.

IFS=$(echo -e \\t\ )

----------------------------------------------
Explanation of above command follows:


When bash interprets the command, it first notices the $( pattern.  This
tells it that I want to execute the command inbetween the parentheses:
echo -en \\t\\n.  The output of this command is then substituted into the
command line; that is, the output of the echo command is put in just after
the equals sign.  The $(...) is equivalent to the backquotes Axalon used
`...` but I think is less confusing - no other dollar signs to confuse
it with.  Not on my keyboard, anyway.

The echo command is sent a switch e, which tells it to interpret special
characters (like \n for newline and \t for tabs).  But why do I put two
backslashes in front if the t, when echo only wants one?  Because the
command is interpreted twice:  once by bash, who sees the \\ and says,
that means put a single backslash in before passing it on to echo.  Echo
sees \t (the one backslash put in by bash before the t) and, because of
the -e, replaces that with a tab.

Echo prints out two characters: a tab, then a newline.  Bash captures
this, and places these after the equals sign in the IFS= command.  Then,
bash interprets this command, which tells it to set a variable named
"IFS" to a tab followed by a newline.

I hope it's explained well.

-Matt Stegman
<[EMAIL PROTECTED]>




Reply via email to