Move everything from /var/adm to /var/log
[unleashed.git] / share / man / man1 / shift.1
blob21406a4f335e7c67f89ee6ec06e8d35164d58cec
1 '\" te
2 .\" Copyright (c) 2007 Sun Microsystems, Inc. - All Rights Reserved.
3 .\" Copyright 1989 AT&T
4 .\" Portions Copyright (c) 1982-2007 AT&T Knowledge Ventures
5 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
6 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
7 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
8 .TH SHIFT 1 "Nov 20, 2007"
9 .SH NAME
10 shift \- shell built-in function to traverse either a shell's argument list or
11 a list of field-separated words
12 .SH SYNOPSIS
13 .SS "sh"
14 .LP
15 .nf
16 \fBshift\fR [\fIn\fR]
17 .fi
19 .SS "csh"
20 .LP
21 .nf
22 \fBshift\fR [\fIvariable\fR]
23 .fi
25 .SS "ksh"
26 .LP
27 .nf
28 \fB*shift\fR [\fIn\fR]
29 .fi
31 .SS "ksh"
32 .LP
33 .nf
34 \fB+shift\fR [\fIn\fR]
35 .fi
37 .SH DESCRIPTION
38 .SS "sh"
39 .sp
40 .LP
41 The positional parameters from \fB$\fR\fIn\fR\fB+1\fR .\|.\|. are renamed
42 \fB$1\fR .\|.\|. . If \fIn\fR is not specified, it is assumed to be 1.
43 .SS "csh"
44 .sp
45 .LP
46 The components of \fIargv\fR, or \fIvariable\fR, if supplied, are shifted to
47 the left, discarding the first component. It is an error for the variable not
48 to be set or to have a null value.
49 .SS "ksh"
50 .sp
51 .LP
52 The positional parameters from \fB$\fR\fIn\fR\fB+1\fR
53 \fB$\fR\fIn\fR\fB+1 .\|.\|.\fR are renamed \fB$1 .\|.\|.\fR, default \fIn\fR is 1. The parameter
54 \fIn\fR can be any arithmetic expression that evaluates to a non-negative
55 number less than or equal to \fB$#\fR.
56 .sp
57 .LP
58 On this manual page, \fBksh\fR(1) commands that are preceded by one or two *
59 (asterisks) are treated specially in the following ways:
60 .RS +4
61 .TP
63 Variable assignment lists preceding the command remain in effect when the
64 command completes.
65 .RE
66 .RS +4
67 .TP
69 \fBI/O\fR redirections are processed after variable assignments.
70 .RE
71 .RS +4
72 .TP
74 Errors cause a script that contains them to abort.
75 .RE
76 .RS +4
77 .TP
79 Words, following a command preceded by ** that are in the format of a
80 variable assignment, are expanded with the same rules as a variable assignment.
81 This means that tilde substitution is performed after the \fB=\fR sign and word
82 splitting and file name generation are not performed.
83 .RE
84 .SS "ksh93"
85 .sp
86 .LP
87 \fBshift\fR is a shell special built-in that shifts the positional parameters
88 to the left by the number of places defined by \fIn\fR, or \fB1\fR if \fIn\fR
89 is omitted. The number of positional parameters remaining is reduced by the
90 number of places that are shifted.
91 .sp
92 .LP
93 If \fIn\fR is specified, it is evaluated as an arithmetic expression to
94 determine the number of places to shift. It is an error to shift more than the
95 number of positional parameters or a negative number of places.
96 .sp
97 .LP
98 The following exit values are returned by \fBshift\fR in \fBksh93\fR:
99 .sp
100 .ne 2
102 \fB\fB0\fR\fR
104 .RS 6n
105 Successful completion. The positional parameters were successfully shifted.
109 .ne 2
111 \fB\fB>0\fR\fR
113 .RS 6n
114 An error occurred.
119 On this manual page, \fBksh93\fR(1) commands that are preceded by one or two
120 \fB+\fR are treated specially in the following ways:
121 .RS +4
124 Variable assignment lists preceding the command remain in effect when the
125 command completes.
127 .RS +4
130 \fBI/O\fR redirections are processed after variable assignments.
132 .RS +4
135 Errors cause a script that contains them to abort.
137 .RS +4
140 They are not valid function names.
142 .RS +4
145 Words, following a command preceded by \fB++\fR that are in the format of a
146 variable assignment, are expanded with the same rules as a variable assignment.
147 This means that tilde substitution is performed after the \fB=\fR sign and
148 field splitting and file name generation are not performed.
150 .SH SEE ALSO
153 \fBcsh\fR(1), \fBksh\fR(1), \fBksh93\fR(1), \fBsh\fR(1), \fBattributes\fR(5)