Re: help, help scripting masters

From: David J. Weller-Fahy <dave-lists-aklug@weller-fahy.com>
Date: Tue Mar 23 2004 - 01:07:56 AKST

* Arthur Corliss <acorliss@nevaeh-linux.org> [2004-03-22 11:13 -0900]:
> On Mon, 22 Mar 2004, David J. Weller-Fahy wrote:
> > After all that, here's how I understand it: If you leave out the
> > braces nothing untoward is *supposed* to happen. However, I've had
> > some bad luck with weird file names (and within file names) when not
> > using the braces. That's my reasoning behind it, anyway. ;]
>
> As I understand it the brace construct was introduced to solve two
> problems:
>
> 1) Provide a mechanism for value-munging (as in the case of array
> subscripting and (sub)string ops)
> 2) Setting variable token boundaries (such as when you want to do
> variable interpolation within a string: echo "foo${foo}bar".
> Without the braces it would try to substitute $foobar instead
> of the desired $foo.)

Yep, never really thought about it, but otherwise (in reference to the
second item) there'd be no way to differentiate between the variable and
the rest of the string. Huh... making new connections all the time. ;]

* Arthur Corliss <acorliss@nevaeh-linux.org> [2004-03-22 11:31 -0900]:
> In terms of the previous embedded whitespace issue, that is correct,
> braces have no impact on that. The problem lies in the order of
> operations within the script engine. The reason why this doesn't
> work:
>
> [snip good stuff]
>
> and handed as a string to the subshell, which uses the field separator
> (white space) to delimit the arguments. Adding the double quotes
> around the variable tells the subshell to ignore field separators
> within the quoted space and treat the entire string as one argument.

Yep, that's the general idea I got during the second email, but hadn't
thought it through in terms of field separators, etc. Actually, I've
never thought that much about those, guess I'll have to start. Have to
start reading the POSIX spec if I'm going to get into these discussions.
Sheesh. ;]

> I suppose that one could make the case that this method of handling is
> less intuitive, but then, there are many common cases in which you'd
> want the field separator to be recognised, such as:
>
> FILES="foo bar"
> mv $FILES archived/

That's the case that I'm most familiar with, as I go to extreme lengths
to avoid spaces in file names. In fact, this will be useful, as I have
a ton of older pics/movies/sounds that have spaces in them, and I'd like
to convert them to underscores... Hrrmmmmm.

Thanks for the lucid (as ever) explanation... Oh, and eddie: Sorry for
the red herring, hope it doesn't stink up the place. ;]

Regards,

-- 
dave [ please don't CC me ]
---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
Received on Tue Mar 23 01:07:26 2004

This archive was generated by hypermail 2.1.8 : Tue Mar 23 2004 - 01:07:26 AKST