bug-bash
[Top][All Lists]
Advanced

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

Re: Tilde expansion gets automatically disabled in shell scripts


From: Chet Ramey
Subject: Re: Tilde expansion gets automatically disabled in shell scripts
Date: Wed, 25 Jul 2001 17:27:01 -0400

> Bash Version: 2.04
> Patch Level: 11
> Release Status: release
> 
> Description:
>       [Detailed description of the problem, suggestion, or complaint.]
> 
> Tilde expansion gets automatically disabled when we assign environment
> variables to variables inside a shell script (I think)

Not really.

I'm assuming that you have a PATH in your environment with the literal
value of '~:~/bin'.

When you have the assignment statement in your script, tilde expansion
is performed, because bash does its normal word expansions on the rhs
of an assignment statement. 

When you don't assign to PATH in your script, it retains its value
from the environment.  Tilde expansion is performed at the same time
as variable expansion, and is not performed on the word `$PATH'
because that has no tildes in it. 

If you want tilde expansion performed on the results of expansion, you
will need to use `eval'. 

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet)

Chet Ramey, CWRU    chet@po.CWRU.Edu    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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