Re: Doesn't MY_ENV=abc printf "${MY_ENV}\n" suppose to print abc?
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
dave@rudedog.org | http://www.rudedog.org/ | ICQ:161669680
UNIX-Apache-Perl-Linux-Firewalls-LDAP-C-C++-DNS-PalmOS-PostgreSQL-MySQL
Reply to: