Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

In the comments to the accepted answer to this Unix & Linux StackExchange question, it is stated that $_ is "one of only some 7 special parameters defined by POSIX". I can't find that definition although I can find eight other special parameters defined by POSIX and I've seen $_ defined in the ksh and bash man pages. Can someone point me to the definition in POSIX?

share|improve this question
1  
Neither the question you link to nor its answers claim that $_ is POSIX. –  terdon May 13 at 22:58
3  
@terdon It's a comment by mikeserv. He's wrong. –  Gilles May 13 at 23:55
    
@terdon I've updated my question to clarify where that statement is in the question. –  jrw32982 May 14 at 2:20

1 Answer 1

up vote 8 down vote accepted

The only reference I can find to the special parameter $_ in POSIX is in the rationale section on Shell Variables. This excerpt implies that it was used by a variety of shells, but not in a standard way by all and was omitted intentionally:

_

(Underscore.) While underscore is historical practice, its overloaded usage in the KornShell is confusing, and it has been omitted from the Shell and Utilities volume of IEEE Std 1003.1-2001.

So it may be used by most or all POSIX-conforming shells, but it is decidedly not defined by POSIX.

share|improve this answer
    
At least Debian dash, Busybox dash and mksh only set $_ when they are interactive. –  Gilles May 13 at 23:59
    
@mtmiller Thanks for that reference –  jrw32982 May 14 at 2:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.