help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Why remove the export attribute of $_ every time after a


From: Chet Ramey
Subject: Re: [Help-bash] Why remove the export attribute of $_ every time after a simple command is executed
Date: Mon, 7 Sep 2015 20:21:19 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.2.0

On 9/7/15 4:01 AM, ziyunfei wrote:
> static void
> bind_lastarg (arg)
>      char *arg;
> {
>   SHELL_VAR *var;
> 
>   if (arg == 0)
>     arg = "";
>   var = bind_variable ("_", arg, 0);
>   VUNSETATTR (var, att_exported);   // <--
> }

Because $_ has different meanings in different contexts.  It only expands
to the final argument of a simple command when that command is executed,
and that is passed to that command in its environment.  It also expands
to the current mail file when checking for mail and is initialized (if not
already set) to the name of the shell at shell startup.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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