Page MenuHomeFreeBSD

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

Authored by 0mp on Sep 9 2019, 9:07 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Apr 23, 12:07 PM
Unknown Object (File)
Dec 20 2023, 4:01 AM
Unknown Object (File)
May 29 2023, 1:55 PM
Unknown Object (File)
Mar 21 2023, 8:27 PM
Unknown Object (File)
Mar 4 2023, 12:26 AM
Subscribers

Details

Reviewers
jilles
bcr
Group Reviewers
manpages
rc
Summary
sh(1): Document the special underscore parameter ("$_")

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 26346
Build 24816: arc lint + arc unit

Event Timeline

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.

bin/sh/sh.1
1329–1330

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

@0mp do you plan to work on this?

@pstef, at some point, I hope so. Nevertheless, if you are willing to commandeer this revision then please do it by all means!