bug-bash
[Top][All Lists]
Advanced

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

Re: Bug report: extended pattern match bug (or "feature" [sic] /inconsis


From: Chet Ramey
Subject: Re: Bug report: extended pattern match bug (or "feature" [sic] /inconsistency)
Date: Sat, 27 Mar 2004 14:22:56 -0500
User-agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; en-US; rv:1.6) Gecko/20040113

linda W wrote:

Pathname expansion is not performed on the rhs of assignment
statements, unquoted or not.


Ok...I guess I missed that somewhere. It seems counter-intuitive since variables are expanded.

It's pretty clearly documented in the first few paragraphs of the
PARAMETERS section.  That lists the expansions performed and explicitly
notes that pathname expansion is not done.

I'll show you a different example that uses no quotes but still shows the difference:

export cur=$a-+([-0-9.a-z])$b


This is not an assignment statement; it's an argument to `export' that
happens to look like an assignment statement, so pathname expansion is
performed.


----
   If it supposed to be expanded, then there would be a different bug to be
reported, but it wasn't expanded in my example:

You are right about this.  I was too hasty in my answer.  `Assignment
statement' arguments to export/readonly/declare/typeset are expanded the
same way as assignment statements.

I suspect the "export" keyword doesn't change the fact that the rest of the
statement is still an assignment statement.

You are correct, the argument is treated as if it were an assignment
statement.  (I changed this an embarrassingly long time ago.)

In my simplistic mind, I sorta thought pathname expansion didn't occur
in quotes, but did occur outside of quotes, thus my surprise when I didn't get pathname
expansion on the simple assignment.

Was there a reason for this design rule? It seems like it would have been more consistent to expand rhs's in assignments, and inhibit expansion by using quotes.

sh has behaved this way since before V7, and POSIX.2 requires it.

Thanks for the explanation, but it still leaves me a bit puzzled as to what the
thoughts were that were going through the designer's head when this was
implemented....just seems inconsistent.

Think of pathname expansion (globbing) as a service provided to
applications by the shell. Before the V7 sh, globbing was performed
by an external application (/etc/glob) and worked only on arguments
to commands.  When Bourne moved it into the shell, to provide consistent
behavior across applications, he preserved the behavior of globbing
only command names and arguments when processing simple commands.

Chet




reply via email to

[Prev in Thread] Current Thread [Next in Thread]