[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: No tilde expansion right after a quotation
From: |
Jon Seymour |
Subject: |
Re: No tilde expansion right after a quotation |
Date: |
Mon, 16 Feb 2009 11:59:10 +1100 |
$# is the number of position parameters in the current context, so it
will always have well defined value.
Technically, $? does not have a well-defined value if there hasn't
been a previously executed foreground pipeline but in practice seems
to have the value 0, so could be used too.
$@ wouldn't work if the positional parameters in the current context
happened to be empty as is easily demonstrated.
echo ${@+~jon} -> empty
echo ${?+~jon} -> /home/jon
echo ${#+~jon} -> /home/jon
jon.
On Mon, Feb 16, 2009 at 11:49 AM, Angel Tsankov
<fn42551@fmi.uni-sofia.bg> wrote:
> Paul Jarc wrote:
>> Jon Seymour <jon.seymour@gmail.com> wrote:
>>> On Mon, Feb 16, 2009 at 10:22 AM, Paul Jarc <prj@po.cwru.edu> wrote:
>>>> CPATH=${CPATH:+$CPATH:}${#+~usr1/blah/blah}
>>>
>>> Out of interest, how does one derive that outcome from the documented
>>> behaviour of bash? That is, which expansion rules are being invoked?
>>
>> It's ${parameter+word}, using $# (which is always set) as the
>> parameter.
>
> How do you know that $# is always set? And what about $@? To what values
> are these parameters set outside any function?
> A more appropriate parameter to use could be $? which, by pure logic, seems
> to be at least as often set as is $#.
>
> -Angel
>
>
>
>
>
>
- Re: No tilde expansion right after a quotation, (continued)
- Re: No tilde expansion right after a quotation, Angel Tsankov, 2009/02/15
- Re: No tilde expansion right after a quotation, Jon Seymour, 2009/02/15
- Re: No tilde expansion right after a quotation, Angel Tsankov, 2009/02/15
- Re: No tilde expansion right after a quotation, Jon Seymour, 2009/02/15
- Re: No tilde expansion right after a quotation, Angel Tsankov, 2009/02/15
- Re: No tilde expansion right after a quotation, Paul Jarc, 2009/02/15
- Re: No tilde expansion right after a quotation, Angel Tsankov, 2009/02/15
- Re: No tilde expansion right after a quotation, Jon Seymour, 2009/02/15
- Re: No tilde expansion right after a quotation, Paul Jarc, 2009/02/15
- Re: No tilde expansion right after a quotation, Angel Tsankov, 2009/02/15
- Re: No tilde expansion right after a quotation,
Jon Seymour <=
- Re: No tilde expansion right after a quotation, Paul Jarc, 2009/02/15
- Re: No tilde expansion right after a quotation, Jon Seymour, 2009/02/15
- Re: No tilde expansion right after a quotation, Paul Jarc, 2009/02/15
- Re: No tilde expansion right after a quotation, Jon Seymour, 2009/02/15
- Re: No tilde expansion right after a quotation, Angel Tsankov, 2009/02/15
- Re: No tilde expansion right after a quotation, Eric Blake, 2009/02/15
- Re: No tilde expansion right after a quotation, Angel Tsankov, 2009/02/16
- Re: No tilde expansion right after a quotation, Dave B, 2009/02/16
- Re: No tilde expansion right after a quotation, Angel Tsankov, 2009/02/16
- Re: No tilde expansion right after a quotation, Eric Blake, 2009/02/16