Page MenuHomeFreeBSD

sh(1): Document the special underscore parameter ("$_")
Needs RevisionPublic

Authored by 0mp on Sep 9 2019, 9:07 AM.


Group Reviewers
sh(1): Document the special underscore parameter ("$_")

Diff Detail

rS FreeBSD src repository
Lint OK
No Unit Test Coverage
Build Status
Buildable 26346
Build 24816: arc lint + arc unit

Event Timeline

0mp created this revision.Sep 9 2019, 9:07 AM
bcr accepted this revision.Sep 9 2019, 3:14 PM
bcr added a subscriber: bcr.

Looks good to me.

This revision is now accepted and ready to land.Sep 9 2019, 3:14 PM
jilles requested changes to this revision.Sep 9 2019, 10:14 PM

Documentation for the _ variable was indeed missing.


The character sequence _ is a name (per "Variables and Parameters" above), so this should be moved under "Special Variables" below.

The term "non-pipeline command" should be "simple command". This term is used elsewhere in the man page and is more precise. For example, a for loop which is a complex command that is not a pipeline still does not set $_ (except for any simple commands nested in it).

Also, it should be mentioned that $_ is only updated by interactive shells executing outside functions (if an interactive shell is currently executing a function, $_ expands to the last word of the last simple command executed before the outermost function call).

This revision now requires changes to proceed.Sep 9 2019, 10:14 PM