On Sat, Aug 02, 2003 at 08:49:36PM +0300, Shaul Karl wrote:

>   According to my understanding of the manual page,
> 
>     $ MY_ENV=abc printf "${MY_ENV}\n"
> 
> Should have print abc. But it does not:
> 
>     $ MY_ENV=abc printf "${MY_ENV}\n"
> 
> What am I missing?

The "MY_ENV=abc printf" syntax sets the environment variable for the
printf subprocess. And, in fact, when printf runs, MY_ENV is truly set
to abc. However, the "${MY_ENV}\n" is expanded *before* printf is
executed, and since MY_ENV is not set in the existing shell, the
expansion results in an empty string. The printf command doesn't even
see MY_ENV in its arguments, all it sees is a single argument that looks
like ``\n''.

-- 
Dave Carrigan
Seattle, WA, USA
[EMAIL PROTECTED] | http://www.rudedog.org/ | ICQ:161669680
UNIX-Apache-Perl-Linux-Firewalls-LDAP-C-C++-DNS-PalmOS-PostgreSQL-MySQL


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to