1shell_builtins(1)                User Commands               shell_builtins(1)
2
3
4

NAME

6       shell_builtins,  case,  for,  foreach,  function,  if,  repeat, select,
7       switch, until, while - shell command interpreter built-in commands
8

DESCRIPTION

10       The shell command interpreters csh(1), ksh(1), ksh93(1), and sh(1) have
11       special  built-in  commands. The commands case, for, foreach, function,
12       if, repeat, select, switch, until, and while are commands in the syntax
13       recognized by the shells. They are described in the Commands section of
14       the manual pages of the respective shells. In ksh93(1), fc, hash, stop,
15       suspend,  times, and type are aliases by default. In ksh93, the follow‐
16       ing built-ins are bound to the /bin pathname by default and are invoked
17       if the pathname search encounters an executable command of that name in
18       the /bin or /usr/bin  directory:  cat,  chown,  getconf,  head,  mkdir,
19       rmdir, tee, uniq, and wc.
20
21
22       The remaining commands listed in the following table are built into the
23       shells for reasons such as efficiency or data sharing  between  command
24       invocations. They are described on their respective manual pages.
25
26
27
28
29                 Command                        Shell
30       ───────────────────────────────────────────────────────────
31       ++**alias                     csh, ksh, ksh93
32       bg                            csh, ksh, ksh93, sh
33       +*break                       csh, ksh, ksh93, sh
34       builtin                       ksh93
35       case                          csh, ksh, ksh93, sh
36       cat                           ksh93
37       cd                            csh, ksh, ksh93, sh
38       chdir                         csh, sh
39       chown                         ksh93
40       command                       ksh93
41       +*continue                    csh, ksh, ksh93, sh
42       dirs                          csh
43       disown                        ksh93
44       echo                          csh, ksh, ksh93, sh
45       +*eval                        csh, ksh, ksh93, sh
46       +*exec                        csh, ksh, ksh93, sh
47       +*exit                        csh, ksh, ksh93, sh
48       ++**export                    ksh, ksh93, sh
49       false                         ksh, ksh93
50       fc                            ksh, ksh93
51       fg                            csh, ksh, ksh93, sh
52       for                           ksh, ksh93, sh
53       foreach                       csh
54       function                      ksh, ksh93
55       getconf                       ksh93
56       getopts                       ksh, ksh93, sh
57       glob                          csh
58       goto                          csh
59       hash                          ksh, ksh93, sh
60       hashstat                      csh
61       head                          ksh93
62       hist                          ksh93
63       history                       csh
64       if                            csh, ksh, ksh93, sh
65       jobs                          csh, ksh, ksh93, sh
66
67       kill                          csh, ksh, ksh93, sh
68       let                           ksh, ksh93,
69       limit                         csh
70       login                         csh, ksh, ksh93, sh
71       logout                        csh
72       mkdir                         ksh93
73       nice                          csh
74       +*newgrp                      ksh, ksh93, sh
75       nohup                         csh
76       notify                        csh
77       onintr                        csh
78       popd                          csh
79       print                         ksh, ksh93
80       printf                        ksh93
81       pushd                         csh
82       pwd                           ksh, ksh93, sh
83       read                          ksh, ksh93, sh
84       ++**readonly                  ksh, ksh93, sh
85       rehash                        csh
86       repeat                        csh
87       +*return                      ksh, ksh93, sh
88       select                        ksh, ksh93
89       +set                          csh, ksh, ksh93, sh
90       setenv                        csh
91       shift                         csh, ksh, ksh93, sh
92       sleep                         ksh93
93       source                        csh
94       stop                          csh, ksh, ksh93, sh
95       suspend                       csh, ksh, sh
96       switch                        csh
97       tee                           ksh93
98       test                          ksh, ksh93, sh
99       time                          csh
100       *times                        ksh, ksh93, sh
101       *+trap                        ksh, ksh93, sh
102       true                          ksh, ksh93
103       type                          ksh, ksh93, sh
104       ++**typeset                   ksh, ksh93
105       ulimit                        ksh, ksh93, sh
106       umask                         csh, ksh, ksh93, sh
107       +unalias                      csh, ksh, ksh93
108       unhash                        csh
109       uniq                          ksh93
110       unlimit                       csh
111       +unset                        csh, ksh, ksh93, sh
112       unsetenv                      csh
113       until                         ksh, ksh93, sh
114       *wait                         csh, ksh, ksh93, sh
115       whence                        ksh, ksh93
116       while                         csh, ksh, ksh93, sh
117
118
119   Bourne Shell, sh, Special Commands
120       Input/output  redirection  is  now  permitted  for these commands. File
121       descriptor 1 is the  default  output  location.  When  Job  Control  is
122       enabled,  additional Special Commands are added to the shell's environ‐
123       ment.
124
125
126       In addition to these built-in reserved command words, sh also uses:
127
128       :              No effect; the command does nothing. A zero exit code is
129                      returned.
130
131
132       .filename      Read  and execute commands from filename and return. The
133                      search path specified by PATH is used to find the direc‐
134                      tory containing filename.
135
136
137   C shell, csh
138       Built-in  commands  are executed within the C shell. If a built-in com‐
139       mand occurs as any component of a pipeline except the last, it is  exe‐
140       cuted  in  a  subshell.  In addition to these built-in reserved command
141       words, csh also uses:
142
143       :    Null command. This command is interpreted, but performs no action.
144
145
146   Korn Shell, ksh, Special Commands
147       Input/Output redirection is permitted. Unless otherwise indicated,  the
148       output  is written on file descriptor 1 and the exit status, when there
149       is no syntax error, is zero.
150
151
152       Commands that are preceded by one or two * (asterisks) are treated spe‐
153       cially in the following ways:
154
155           1.     Variable  assignment  lists  preceding the command remain in
156                  effect when the command completes.
157
158           2.     I/O redirections are processed after variable assignments.
159
160           3.     Errors cause a script that contains them to abort.
161
162           4.     Words, following a command preceded by ** that  are  in  the
163                  format  of a variable assignment, are expanded with the same
164                  rules as a variable assignment. This means that  tilde  sub‐
165                  stitution  is  performed after the = sign and word splitting
166                  and file name generation are not performed.
167
168
169       In addition to these built-in reserved command words, ksh also uses:
170
171       * : [ arg ... ]              The command only expands parameters.
172
173
174       * .file [ arg ... ]          Read the complete file  then  execute  the
175                                    commands. The commands are executed in the
176                                    current shell environment. The search path
177                                    specified  by  PATH  is  used  to find the
178                                    directory containing file.  If  any  argu‐
179                                    ments  arg  are specified, they become the
180                                    positional  parameters.   Otherwise,   the
181                                    positional  parameters  are unchanged. The
182                                    exit status is the exit status of the last
183                                    command  executed.  the  loop  termination
184                                    test.
185
186
187   Korn Shell, ksh93, Special Commands
188       Input/Output redirection is permitted. Unless otherwise indicated,  the
189       output  is written on file descriptor 1 and the exit status, when there
190       is no syntax error, is zero.
191
192
193       Except for :, true, false, echo, newgrp, and login, all  built-in  com‐
194       mands  accept  --  to  indicate end of options. They also interpret the
195       option --man as a request to display  the  manual  page  onto  standard
196       error and -? as a help request which prints a usage message on standard
197       error.
198
199
200       Commands that are preceded by one or two + are treated specially in the
201       following ways:
202
203           1.     Variable  assignment  lists  preceding the command remain in
204                  effect when the command completes.
205
206           2.     I/O redirections are processed after variable assignments.
207
208           3.     Errors cause a script that contains them to abort.
209
210           4.     They are not valid function names.
211
212           5.     Words, following a command preceded by ++ that  are  in  the
213                  format  of a variable assignment, are expanded with the same
214                  rules as a variable assignment. This means that  tilde  sub‐
215                  stitution  is performed after the = sign and field splitting
216                  and file name generation are not performed.
217
218
219       In addition to these built-in reserved command words, ksh93 also uses:
220
221       : [ arg ... ]              The command only expands parameters.
222
223
224       .name [ arg ... ]          If name is a function defined with the func‐
225                                  tion name reserved word syntax, the function
226                                  is executed in the current  environment  (as
227                                  if  it had been defined with the name() syn‐
228                                  tax.) Otherwise if name refers  to  a  file,
229                                  the  file  is  read  in its entirety and the
230                                  commands are executed in the  current  shell
231                                  environment.  The  search  path specified by
232                                  PATH is used to find the directory  contain‐
233                                  ing the file. If any arguments arg are spec‐
234                                  ified, they become the positional parameters
235                                  while processing the . command and the orig‐
236                                  inal positional parameters are restored upon
237                                  completion. Otherwise the positional parame‐
238                                  ters are unchanged. The exit status  is  the
239                                  exit status of the last command executed.
240
241

SEE ALSO

243       Intro(1), alias(1), break(1), builtin(1), cd(1), chmod(1), csh(1), dis‐
244       own(1), echo(1), exec(1), exit(1), find(1),  getoptcvt(1),  getopts(1),
245       glob(1),  hash(1),  history(1),  jobs(1),  kill(1),  ksh(1),  ksh93(1),
246       let(1), limit(1), login(1), logout(1),  newgrp(1),  nice(1),  nohup(1),
247       print(1),  printf(1),  pwd(1),  read(1),  readonly(1),  set(1),  sh(1),
248       shift(1),  sleep(1),  suspend(1),  test(1)test(1),  test(1B),  time(1),
249       times(1),  trap(1),  typeset(1), umask(1), wait(1), chdir(2), chmod(2),
250       creat(2), umask(2), getopt(3C), profile(4), environ(5)
251
252
253
254SunOS 5.11                        20 Nov 2007                shell_builtins(1)
Impressum