help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] inconsistency in expansions


From: Bill Gradwohl
Subject: Re: [Help-bash] inconsistency in expansions
Date: Mon, 7 May 2012 07:09:15 -0600

On Sun, May 6, 2012 at 6:07 PM, Dan Douglas <address@hidden> wrote:
${$x} isn't a valid expansion, so it throws an error, the pattern isn't matched, and nothing happens.

I see it produces an error, but I still don't see why. If $x expands to 3 why don't I get ${3} and then the expansion of ${3}? Why is it illegal? What bash rule makes it so?

${$#} expands to the shell's PID, and tries to chop off a pattern matching the empty string at the beginning, which doesn't match the pattern at the end of "$*", so nothing happens. "$3" expands to "canary", which does match the pattern, so the string is modified.
 
Here you lost me all together. $$ is the shell PID. How do you see this as having to do with a PID? You're probably right, but I don't see by what logic you arrive at that conclusion.

Aren't expansions done from the inside out? Since $# is 3, shouldn't $# be expanded first to produce ${3} and then that expanded to, in my example, the last past parameter? I can answer my own question because I see it doesn't work, but I want to understand WHY it doesn't work.

It's the WHY I'm after. I can always code a work around.


--
Bill Gradwohl


reply via email to

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