-
Notifications
You must be signed in to change notification settings - Fork 38
/
sh.1
2264 lines (2264 loc) · 51.8 KB
/
sh.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
.\" $OpenBSD: sh.1,v 1.158 2024/03/06 06:26:22 jmc Exp $
.\"
.\" Copyright (c) 2015 Jason McIntyre <[email protected]>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: March 6 2024 $
.Dt SH 1
.Os
.Sh NAME
.Nm sh
.Nd command language interpreter
.Sh SYNOPSIS
.Nm sh
.Op Fl abCefhimnuvx
.Op Fl o Ar option
.Op Fl c Ar string | Fl s | Ar file
.Sh DESCRIPTION
The
.Nm
utility is a
.Em command language interpreter :
it reads one or more commands,
either from the command line or from a file
(a shell script),
and then sets about executing those commands.
Thus it is the
main interface between the user and the operating system.
.Pp
This version of
.Nm
is actually
.Nm ksh
in disguise.
As such, it also supports the features described in
.Xr ksh 1 .
This manual page describes only the parts
relevant to a POSIX compliant
.Nm .
If portability is a concern,
use only those features described in this page.
.Pp
The shell receives input as follows:
.Pp
.Bl -tag -width "-c stringXXX" -offset indent -compact
.It Fl c Ar string
Read commands from
.Ar string .
.It Fl s
Read commands from standard input
(the default).
.It Ar file
Read commands from
.Ar file .
.El
.Pp
The options below can be specified with a
.Sq Cm +
rather than
.Sq Fl ,
meaning to unset the option.
They can also be set or unset using the
.Ic set
command.
Some options have equivalent long names,
indicated at the start of the description,
which can be used with the
.Fl o
option.
.Bl -tag -width Ds
.It Fl a
Allexport.
Variable assignments are exported to all child processes
of the running shell.
If the assignment precedes a command it does not persist
after that command has finished running,
unless the command is a special builtin
or one of the builtins
.Ic getopts
or
.Ic read
makes the assignment.
.It Fl b
Notify.
The user is given notice asynchronously when background jobs complete.
.It Fl C
Noclobber.
Do not permit the redirection operator
.Pq Sq >
to clobber (overwrite) existing files.
.It Fl e
Errexit.
Exit the shell immediately should an error occur or a command fail.
For pipelines and
.Cm &&
and
.Cm ||
constructs, only exit if the last component fails.
Errexit is ignored for
.Ic while ,
.Ic until ,
.Ic if ,
and
.Ic elif
lists and pipelines beginning
.Sq !\& .
.It Fl f
Noglob.
Do not expand file name patterns.
.It Fl h
When a utility is first executed,
hash (record) its location
so that future invocations do not need to search for it.
.It Fl i
Enable behaviour convenient for an interactive shell.
This option is set by default
if the session is attached to a terminal.
.It Fl m
Monitor.
Fully enable job control:
enable the
.Ic bg
and
.Ic fg
builtins;
report completion status when jobs finish;
report when a foreground process stops;
and report when a job changes status.
The processes of a job share their own process group.
This option is set by default for interactive shells.
.It Fl n
Noexec.
Read commands but do not execute them \(en
useful for checking syntax errors in scripts.
This option is ignored for interactive shells.
.It Fl o Ar option
Specify an option by its long name.
Those described below have no equivalent option letter:
.Pp
.Bl -tag -width "ignoreeof" -offset 3n -compact
.It ignoreeof
Ignore an end-of-file
.Pq Sq ^D .
EOF normally logs a user out,
so setting this can prevent accidental logouts
(the user will need to explicitly use the
.Ic exit
command).
.It nolog
Do not enter function definitions into command history.
.It posix
Enable POSIX mode
(see
.Sx STANDARDS ) .
.It vi
Enable
.Xr vi 1
command line editing.
.El
.It Fl u
Nounset.
If a command references an unset parameter,
write an error to standard output instead of executing the command.
This option is ignored for the special parameters
.Sq *
and
.Sq @ .
If the shell is not interactive,
immediately exit.
.It Fl v
Verbose.
Write input to standard error after reading it.
.It Fl x
Xtrace.
Write a trace for each command to standard error after expanding it,
and before executing it.
.El
.Sh BUILTINS
The shell has a number of
.Em built-ins
available:
utilities that are included as part of the shell.
The shell does not need to search for them
and can execute them directly.
.Pp
A number of built-ins are special in that
a syntax error can cause a running shell to abort,
and, after the built-in completes,
variable assignments remain in the current environment.
The following built-ins are special:
.Ic .\& , :\& , break , continue ,
.Ic eval , exec , exit , export ,
.Ic readonly , return , set , shift ,
.Ic times , trap ,
and
.Ic unset .
.Pp
The built-ins available to
.Nm
are listed below.
Unless otherwise indicated,
they exit 0 on success,
and >0 if an error occurs.
.Bl -tag -width 2n
.It Ic .\& Ar file
Execute the commands in
.Ar file ,
in the current environment.
The actual file need not be executable,
and its location is determined by searching
.Ev PATH
if there are no slashes in the filename.
The exit status is that of the last command returned,
or zero if no commands were executed.
If no readable file can be found,
a non-interactive shell will abort;
an interactive shell writes an error message
and returns a non-zero exit status.
.It Ic :\& Op Ar arg ...
The
.Ic :\&
command does nothing \(en
it is a placeholder for when a command is required.
Its exit status is always zero.
.It Ic alias Op Ar name Ns Oo = Ns Ar value Oc Ar ...
Define an alias
.Ar name
to
.Ar value ;
when the shell encounters a command name that is an alias,
its value is substituted.
If
.Ar value
ends in a blank,
the next word is checked for alias substitution too.
If only a
.Ar name
is specified,
display the value of that alias;
if no arguments are given,
list all aliases and their values.
Aliases are visible in the current environment and that of subshells,
but not by the parent process of the current shell
or by utilities invoked by it.
.It Ic bg Op Ar id ...
Select a job by
.Ar id
(see the
.Ic jobs
command, below)
to run in the background.
The default job is
.Qq %+ .
.It Ic break Op Ar n
Exit from the innermost
.Ic for , while ,
or
.Ic until
loop,
or from loop level
.Ar n .
.It Ic cd Oo Fl L | P Oc Op Ar dir
Change the current working directory to
.Ar dir ,
or
.Ev $HOME
by default.
If
.Ar dir
is set to
.Sq - ,
change to the previous working directory and
print the (now current) working directory.
If
.Ar dir
does not begin with a slash or dot,
.Ev CDPATH
is searched for the directory.
.Pp
The options to the
.Ic cd
command are as follows:
.Pp
.Bl -tag -width Ds -offset 3n -compact
.It Fl L
Do not resolve symbolic links before processing
.Qq ..
components.
.It Fl P
Resolve symbolic links before processing
.Qq ..
components.
.El
.It Ic command Oo Fl p | V | v Oc Ar command Op Ar arg ...
Invoke
.Ar command
(and any optional arguments),
overriding any functions with the same name,
and without any of the properties that special built-ins have.
.Pp
The options to
.Ic command
are as follows:
.Pp
.Bl -tag -width Ds -offset 3n -compact
.It Fl p
Use a default value for
.Ev PATH
to search for the command.
.It Fl V
Do not invoke
.Ar command ,
but identify how the shell will interpret it
(such as a function or special built-in).
.It Fl v
Do not invoke
.Ar command ,
but identify the pathname the shell will use to run it.
For aliases, a command to define that alias is printed.
For shell reserved words, shell functions, and built-in utilities,
just the name is printed.
.El
.Pp
The exit status is that of
.Ar command ,
or 126 if
.Ar command
could not be invoked,
or 127 if an error occurred in
.Ic command
itself or
.Ar command
could not be found.
If the options
.Fl V
or
.Fl v
are given,
the exit status is 0 on success,
or >0 if an error occurs.
.It Ic continue Op Ar n
Go directly to the next iteration of the innermost
.Ic for , while ,
or
.Ic until
loop,
or from loop level
.Ar n .
.It Ic eval Op Ar arg ...
Concatenate the arguments given
and interpret them as a command.
The exit status is that of the resulting command,
zero if no arguments are given,
or >0 if the resulting command could not be correctly parsed.
.It Ic exec Op Ar command Op Ar arg ...
Replace the shell with
.Ar command
(and any optional arguments),
without creating a new process.
The exit status is that of
.Ar command ,
or 126 if
.Ar command
could not be invoked,
or 127 if
.Ar command
could not be found.
If no command is given but a redirection happens,
the exit status is 1\(en125;
otherwise
.Ic exec
returns 0.
.It Ic exit Op Ar n
Exit the shell with exit status
.Ar n ,
or that of the last command executed.
.It Ic export Oo Fl p Oc Ar name Ns Oo = Ns Ar value Oc Ar ...
Make the variable
.Ar name
visible to subsequently run commands,
optionally setting it to
.Ar value .
.Pp
The options to the
.Ic export
command are as follows:
.Pp
.Bl -tag -width Ds -offset 3n -compact
.It Fl p
List all exported variables in a manner that can be reinput to the shell.
.El
.It Ic false
Return a false (non-zero) value.
.It Xo
.Ic fc
.Op Fl lnr
.Op Fl e Ar editor
.Op Fl s Op Ar old Ns = Ns Ar new
.Op Ar first Op Ar last
.Xc
Edit commands from command history using
.Xr ed 1 .
After editing,
the new commands are executed by the shell.
.Pp
The options to the
.Ic fc
command are as follows:
.Pp
.Bl -tag -width "-s [old=new]" -offset 3n -compact
.It Fl e Ar editor
Edit commands using
.Ar editor .
See also
.Ev FCEDIT .
.It Fl l
List the command history.
.It Fl ln
List the command history without command numbers.
.It Fl r
Edit or list
.Pq Fl lr
commands in reverse order.
.It Fl s Op Ar old Ns = Ns Ar new
Reexecute a single command
without invoking an editor.
The first occurrence of the string
.Ar old
in the command is replaced by
.Ar new .
.El
.Pp
A range of commands can be specified,
.Ar first
to
.Ar last .
Their format can be numerical,
to select by command number;
.Sq - Ns Ar n ,
to select a command executed that number of commands previous;
or a string which matches the beginning of the command.
If no range is given,
the last command in command history is edited,
or reexecuted
.Pq Fl s ,
or the previous 16 commands in command history are listed
.Pq Fl l .
If
.Ar first
is newer than
.Ar last ,
commands are processed in reverse order
(as if
.Fl r
had been given);
if either are out of range,
the oldest or newest values are used.
.It Ic fg Op Ar id ...
Select a job by
.Ar id
(see the
.Ic jobs
command, below)
to run in the foreground.
The default job is
.Qq %+ .
.It Ic getopts Ar optstring name Op Ar arg ...
When invoked,
.Ic getopts
processes the positional parameters
(or any
.Ar arg
passed to it)
as a list of options and option arguments.
.Ic getopts
sets the variable
.Ar name
to the option found,
.Ev OPTARG
to its argument,
and
.Ev OPTIND
to the index of the next variable to be processed.
.Pp
The string
.Ar optstring
contains a list of acceptable options;
a colon following an option indicates it requires an argument.
If an option not recognised by
.Ar optstring
is found,
.Ar name
is set to
.Sq ?\& ;
if the first character of
.Ar optstring
is a colon,
.Ev OPTARG
is set to the unsupported option,
otherwise an error message is displayed.
.Pp
The following code fragment shows how one might process the arguments
for a command that can take the option
.Fl a
and the option
.Fl o ,
which requires an argument.
.Bd -literal -offset indent
while getopts ao: name
do
case $name in
a) flag=1 ;;
o) oarg=$OPTARG ;;
?) echo "Usage: ..."; exit 2 ;;
esac
done
shift $(($OPTIND - 1))
echo "Non-option arguments: " "$@"
.Ed
.It Ic hash Op Fl r | Ar utility
Add
.Ar utility
to the hash list
or remove
.Pq Fl r
all utilities from the hash list.
Without arguments, show the utilities currently hashed.
.It Ic jobs Oo Fl l | p Oc Op Ar id ...
Display the status of all jobs in the current shell environment,
or those selected by
.Ar id .
.Pp
The options to the
.Ic jobs
command are as follows:
.Pp
.Bl -tag -width Ds -offset 3n -compact
.It Fl l
Additionally display the process group ID.
.It Fl p
Display only the process group ID.
.El
.Pp
Job
.Ar id
can be selected in one of the following ways:
.Pp
.Bl -tag -width "%?string" -offset 3n -compact
.It %%
The current job.
.It %+
The current job.
.It %-
The previous job.
.It % Ns Ar n
Job number
.Ar n .
.It % Ns Ar string
Job with command matching
.Ar string .
.It %? Ns Ar string
Job with command containing
.Ar string .
.El
.It Xo
.Ic kill
.Op Fl l Op Ar signal
.Op Fl s Ar signal
.Oo Fl Ar signal Oc Ar pid ...
.Xc
Send a signal,
by default
.Dv SIGTERM ,
to the process with ID
.Ar pid .
.Pp
The options to the
.Ic kill
command are as follows:
.Pp
.Bl -tag -width "-l [signal]" -offset 3n -compact
.It Fl l Op Ar signal
List all supported signals,
or the signal name corresponding to
.Ar signal
number or the exit status of a command killed by a signal.
.It Fl s Ar signal
Send the process
.Ar signal
name.
.It Fl Ar signal
Send the process
.Ar signal
name or number.
.It Ar pid
A process ID,
process group ID,
or a job ID (see
.Ic jobs ,
above).
The process ID 0 signals all processes in the current process group.
.El
.Pp
The supported signal numbers are:
.Pp
.Bl -tag -width Ds -offset 3n -compact
.It " 0"
Do not signal a process,
but determine whether an ID exists.
.It " 1"
.Dv SIGHUP :
Terminal line hangup.
.It " 2"
.Dv SIGINT :
Interrupt a program.
.It " 3"
.Dv SIGQUIT :
Quit a program.
.It " 6"
.Dv SIGABRT :
Call
.Xr abort 3 .
.It " 9"
.Dv SIGKILL :
Kill a program.
Cannot be caught or ignored.
.It "14"
.Dv SIGALRM :
Real-time timer expired.
.It "15"
.Dv SIGTERM :
Software termination signal.
.El
.It Ic pwd Op Fl L | P
Print the current working directory.
.Pp
The options to the
.Ic pwd
command are as follows:
.Pp
.Bl -tag -width Ds -offset 3n -compact
.It Fl L
Print the logical path to the current working directory
i.e. display symbolic links followed.
.It Fl P
Print the physical path to the current working directory
i.e. display symbolic links resolved.
.El
.Pp
If both options are given,
the last specified is used;
if none are given,
the default is
.Fl L .
.It Ic read Oo Fl r Oc Ar name ...
Read a line from standard input.
The line is split into fields,
with each field assigned to a variable,
.Ar name ,
in turn
(first field assigned to first variable, and so on).
If there are more fields than variables,
the last variable will contain all the remaining fields.
If there are more variables than fields,
the remaining variables are set to empty strings.
A backslash in the input line causes the shell to prompt for further input.
.Pp
The options to the
.Ic read
command are as follows:
.Pp
.Bl -tag -width Ds -offset 3n -compact
.It Fl r
Ignore backslash sequences.
.El
.It Ic readonly Oo Fl p Oc Ar name Ns Op = Ns Ar value
Mark variable
.Ar name
as readonly,
and optionally set it to
.Ar value .
Readonly variables cannot be later assigned values or unset.
.Pp
The options to the
.Ic readonly
command are as follows:
.Pp
.Bl -tag -width Ds -offset 3n -compact
.It Fl p
Display the names and values of all readonly variables
in a manner which can be reinput to the shell.
.El
.It Ic return Op Ar n
Exit the current function or
.Ic .\&
script with exit status
.Ar n ,
or that of the last command executed.
.It Xo
.Ic set
.Op Fl abCefhmnuvx
.Op Fl o Op Ar option
.Op Ar arg ...
.Xc
Set options and positional parameters.
Without options or arguments,
display the names and values of all shell variables.
.Pp
The options are described in the options description
at the beginning of this manual.
The sequence
.Ql set -o
displays the current option settings;
the sequence
.Ql set +o
displays,
in a format suitable to be reinput to the shell,
a command suitable to achieve the current option settings.
.Pp
Any arguments are assigned to the positional parameters,
with the special parameter
.Sq #
set to the number of positional parameters.
The sequence
.Ql set --
indicates an end to option processing
(i.e. only arguments follow);
.Ql set --
by itself unsets all positional parameters
and sets
.Sq #
to zero.
.It Ic shift Op Ar n
Shift the positional parameters
.Ar n
times
(by default once).
Parameter 1 takes the value of parameter
.Sq 1+ Ns Ar n ,
parameter 2 takes
.Sq 2+ Ns Ar n ,
and so on.
Parameters
.Sq #
down to
.Sq Po #\(mi Ns Ar n Pc Ns +1
are unset and
.Sq #
is updated to the new number of positional parameters.
If
.Ar n
is 0,
no change occurs.
.It Ic times
Display accumulated process times for the shell (user and system)
and all child processes (user and system).
.It Ic trap Op Ar action signal ...
Perform
.Ar action
whenever
.Ar signal
is caught.
Without arguments,
display a list of all traps and actions,
in a format suitable to be reinput to the shell.
.Pp
If
.Ar action
is
.Sq -
or an integer,
reset
.Ar signal
to its default value;
if it is empty
.Pq Qq ,
ignore
.Ar signal .
If
.Ar signal
is
.Qq EXIT
or 0,
perform
.Ar action
when the shell exits;
otherwise
.Ar signal
should be a signal name
(without the SIG prefix)
or number.
.It Ic true
Return a true (zero) value.
.It Ic type Ar command ...
For each
.Ar command ,
show how the shell would interpret it.
.It Ic ulimit Op Fl f Ar n
Limit the maximum size of a file that can be created to
.Ar n
blocks.
Without arguments,
display the current file size limit.
.It Ic umask Oo Fl S Oc Op Ar mask
Set the file mode creation mask to
.Ar mask .
The creation mask determines the default permissions
a newly created file or directory will have.
If
.Ar mask
is not specified,
display the current creation mask.
.Pp
The options to the
.Ic umask
command are as follows:
.Pp
.Bl -tag -width Ds -offset 3n -compact
.It Fl S
Display symbolic output.
.El
.Pp
See
.Xr chmod 1
for the format of
.Ar mask .
.It Ic unalias Oo Fl a Oc Ar name ...
Remove the alias definition of alias
.Ar name .
.Pp
The options to the
.Ic unalias
command are as follows:
.Pp
.Bl -tag -width Ds -offset 3n -compact
.It Fl a
Remove all alias definitions.
.El
.It Ic unset Oo Fl fv Oc Ar name ...
Unset variable or function
.Ar name .
.Pp
The options to the
.Ic unset
command are as follows:
.Pp
.Bl -tag -width Ds -offset 3n -compact
.It Fl f
Treat
.Ar name
as a function.
.It Fl v
Treat
.Ar name
as a variable (the default).
.El
.It Ic wait Op Ar pid ...
Wait until all the processes specified by process or job ID
.Ar pid
have terminated.
If no
.Ar pid
is specified,
wait until all processes have terminated.
The exit status is 0 on success,
1\(en126 if an error occurs,
or 127 if
.Ar pid
was unknown.
.El
.Sh COMMAND HISTORY AND COMMAND LINE EDITING
When a shell is interactive,
it keeps a record of commands run in a
.Em command history ,
either internally in memory or in a file,
as determined by
.Dv HISTFILE .
When
.Cm vi
command line editing mode is enabled
.Pq set -o vi ,
the command line and all the commands in command history
can be edited using commands similar to those of
.Xr vi 1 .
.Pp
There are two modes,
.Em interactive
and
.Em command .
The shell starts in interactive mode.
In this mode text is entered normally.
A
.Aq newline
executes the current command line.
The command line, unless empty, is entered into command history.
The
.Aq ESC
key is used to enter command mode,
where commands similar to those used by
.Xr vi 1
are available.
A Ctrl-L sequence
.Pq ^L
can be used in this mode to
redraw the current command line.
.Pp
Where noted,
some commands may be preceded by a numerical
.Ar count ,
which causes the command to be repeated that number of times.
The term
.Em word
is used to denote a sequence of letters, digits, or underscores;
.Em bigword
denotes a sequence of whitespace delineated characters.
.Pp
The commands for command mode:
.Bl -tag -width "<newline>"
.It Ic =
Display the possible shell word expansion.
.It Ic \e
Perform pathname expansion on the current word,
matching the largest possible unique expansion,
then enter insert mode.
.It Ic *
Perform pathname expansion on the current word,
substituting every possible expansion,
then enter insert mode.
.It Ic @ Ns Ar c
Perform the commands defined by the alias
.No _ Ns Ar c ,
where
.Ar c
is a single letter alphabetical character.
.It Oo Ar count Oc Ns Ic ~
Convert the character from lowercase to upper or vice versa.
.It Oo Ar count Oc Ns Ic .\&
Repeat the most recent non-motion command.
If no
.Ar count
is given, use that of the repeated command,
if any.
.It Oo Ar n Oc Ns Ic v
Use
.Xr vi 1
to edit command number
.Ar n
in command history,
or the current command if none given.
.It Xo
.Oo Ar count Oc Ns Ic l ,
.Oo Ar count Oc Ns Aq space
.Xc
Move right.
.It Oo Ar count Oc Ns Ic h
Move left.
.It Oo Ar count Oc Ns Ic w
Move to the start of the next word.
.It Oo Ar count Oc Ns Ic W
Move to the start of the next big word.
.It Oo Ar count Oc Ns Ic e
Move to the end of the current word,
or the end of the next word if the cursor is currently
at the end of a word.
.It Oo Ar count Oc Ns Ic E
Move to the end of the current bigword,
or the end of the next bigword if the cursor is currently
at the end of a bigword.
.It Oo Ar count Oc Ns Ic b
Move to the start of the current word,
or the start of the next word if the cursor is currently
at the start of a word.
.It Oo Ar count Oc Ns Ic B
Move to the start of the current bigword,
or the start of the next bigword if the cursor is currently
at the start of a bigword.
.It Ic ^
Move to the first non-blank character.
.It Ic $
Move to the end of the current line.
.It Ic 0
Move to the beginning of the current line.
.It Oo Ar count Oc Ns Ic |\&
Move to the beginning of the current line
or the character position specified by
.Ar count .
.It Oo Ar count Oc Ns Ic f Ns Ar c
Move to the next instance of the
character
.Ar c .