[Top][All Lists]

[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: Tue, 8 Sep 2015 11:27:47 -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 9:44 PM, ziyunfei wrote:
> On Sep 8, 2015, at 8:21 AM, Chet Ramey <address@hidden> wrote:
>> 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.
> Thanks for replying, actually I know $_ has three different meanings 
> depending on when and where it's used. but I just want to ask: what will 
> happen if we allow $_ to be an environment variable when it represents the 
> last arg, like ksh does.

I see what you mean.  What use case do you have for making it exportable?
The feature has been around over 25 years, and this is the first time the
subject has come up.  It's tough to recreate the past, but I imagine the
rationale was something along the lines that the information is only useful
in the current shell.

``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden

reply via email to

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