Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/sh Correct description of the trap command (make it posi...



details:   https://anonhg.NetBSD.org/src/rev/814ad0a12483
branches:  trunk
changeset: 823629:814ad0a12483
user:      kre <kre%NetBSD.org@localhost>
date:      Sat Apr 29 15:26:44 2017 +0000

description:
Correct description of the trap command (make it posix compatible)
and add a couple more examples.   Also terminate a few sentences...

diffstat:

 bin/sh/sh.1 |  38 ++++++++++++++++++++++++++++++--------
 1 files changed, 30 insertions(+), 8 deletions(-)

diffs (86 lines):

diff -r ec38af90d0f0 -r 814ad0a12483 bin/sh/sh.1
--- a/bin/sh/sh.1       Sat Apr 29 15:14:28 2017 +0000
+++ b/bin/sh/sh.1       Sat Apr 29 15:26:44 2017 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: sh.1,v 1.131 2017/04/14 08:48:01 abhinav Exp $
+.\"    $NetBSD: sh.1,v 1.132 2017/04/29 15:26:44 kre Exp $
 .\" Copyright (c) 1991, 1993
 .\"    The Regents of the University of California.  All rights reserved.
 .\"
@@ -31,7 +31,7 @@
 .\"
 .\"    @(#)sh.1        8.6 (Berkeley) 5/4/95
 .\"
-.Dd March 20, 2017
+.Dd April 29, 2017
 .Dt SH 1
 .ds flags abCEeFfhnuvxIimpqV
 .Os
@@ -2037,7 +2037,8 @@
 .Dq $# )
 before the shift.
 .It trap Oo Fl l Oc
-.It trap Oo Ar action Oc Ar signal ...
+.It trap Ar action signal ...
+.It trap Ar N signal ...
 Cause the shell to parse and execute action when any of the specified
 signals are received.
 The signals are specified by signal number or as the name of the signal.
@@ -2051,9 +2052,20 @@
 may be null, which cause the specified signals to be ignored.
 With
 .Ar action
-omitted or set to
+set to
 .Sq -
 the specified signals are set to their default action.
+If the first
+.Ar signal
+is specified in its numeric form, then
+.Ar action
+can be ommitted to achieve the same effect.
+This archaic,
+but still standard,
+form should not be relied upon, use the explicit
+.Sq -
+action.
+.Pp
 When the shell forks off a subshell, it resets trapped (but not ignored)
 signals to the default action.
 On non-interactive shells, the
@@ -2077,21 +2089,31 @@
 .Pp
 .Dl trap
 .Pp
-List trapped signals and their corresponding action
+List trapped signals and their corresponding action.
 .Pp
 .Dl trap -l
 .Pp
-Print a list of valid signals
+Print a list of valid signals.
 .Pp
 .Dl trap '' INT QUIT tstp 30
 .Pp
-Ignore signals INT QUIT TSTP USR1
+Ignore signals INT QUIT TSTP USR1.
 .Pp
 .Dl trap date INT
 .Pp
 Run the
 .Dq date
-command (print the date) upon receiving signal INT
+command (print the date) upon receiving signal INT.
+.Pp
+.Dl trap HUP INT
+.Pp
+Run the
+.Dq HUP
+command upon receiving signal INT.
+.Pp
+.Dl trap 1 2
+.Pp
+Reset the actions for signals 1 (HUP) and 2 (INT) to their defaults.
 .It type Op Ar name ...
 Interpret each name as a command and print the resolution of the command
 search.



Home | Main Index | Thread Index | Old Index