Re: [SLE] bash Script Using Filenames with Embedded Spaces



On 2006-11-07 09:46, Randall R Schulz wrote:

OK, you've answered a lot of questions, but raised a few more. (No
offence intended, but I do think Joachim has given a better explanation
of this.)
<snip>
Nonetheless, my point was that if you have a character such as an
en-space (or it's fatter sibling, em-space, which is the width of a
lower-case 'm'), it can be expanded unquoted in an argument list
without the en-space causing a break in the argument as a regular space
would.

In this instance, we are talking about filenames that clearly have
regular spaces as part of their filenames, so I don't see how speaking
of en- or em-spaces is relevant. I don't believe there is any way a
regular space could be translated to any other kind of space just as
part of any glob processing.
Absolutely not. Ls is not special in this way. The only special
treatment is the expansion of the glob pattern...
I didn't say ls is special in any way; what I did say (not very well, I
admit) is that the ls commandline syntax is "ls ... <space delimited
list of filespecs>" and thus, without any (double) quotes around the
variable name, "ls ... $i" will produce unexpected results if the value
of $i is a filespec containing spaces.

<snip>
for i in '*.m3u'; do echo $i; ls -l $i; done


In this case, the glob expansion of *.m3u is happening upon each
unquoted reference in the body of the loop.

As I just found running "echo *.m3u" in that directory, on the
commandline. -That- is something I certainly did not expect -- :-)
Did someone say the bash commandline isn't interesting and fun? :-)


I think so. I do tons of BASH programming.
Fortunately for you, I do not do all that much, or you might suddenly
find your inbox full of messages starting "Help, I cannot figure out
what this thing is doing...." :-)

--
Check the headers for your unsubscription address
For additional commands send e-mail to suse-linux-e-help@xxxxxxxx
Also check the archives at http://lists.suse.com
Please read the FAQs: suse-linux-e-faq@xxxxxxxx