Page MenuHomeFreeBSD

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

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

Details

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

Diff Detail

Repository
rS FreeBSD src repository
Lint
Lint OK
Unit
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.

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