Repository navigation
Expand file tree
/
Copy pathman_1_simple_shell
More file actions
1898 lines (1891 loc) · 55.1 KB
/
Copy pathman_1_simple_shell
File metadata and controls
1898 lines (1891 loc) · 55.1 KB
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
.TH "SCARJO SHELL" 1 "2017 APR 14" LOCAL "HOLBERTON SCHOOL BATCH 2"
.SH NAME
ScarJo Shell \- a simple UNIX command interpreter (shell) built as an end of term project for Holberton School
.SH SYNOPSIS
.B scarjo
[command_string | file]
.SH DESCRIPTION
.B ScarJo Shell
is an \fBsh\fR-compatible command language interpreter that executes limited commands read from the standard input.
.PP
.B ScarJo Shell
is \fBnot\fR intended to be a \fBfully\fR conformant implementation of the Shell and Utilities portion of the IEEE POSIX specification (IEEE Standard 1003.1).
.SH DEFINITIONS
.PP
The following definitions are used throughout the rest of this
document.
.PD 0
.TP
.B blank
A space or tab.
.TP
.B word
A sequence of characters considered as a single unit by the shell.
Also known as a
.BR token .
.TP
.B name
A
.I word
consisting only of alphanumeric characters and underscores, and
beginning with an alphabetic character or an underscore. Also
referred to as an
.BR identifier .
.TP
.B metacharacters and control operators
ScarJo Shell only recognizes the following:
A character that, when unquoted, separates words. One of the following:
.br
.RS
.PP
.if t \fBspace tab\fP
.if n \fBspace tab\fP
.RE
.PP
.TP
.B control operator
A \fItoken\fP that performs a control function. It is one of the following
symbols:
.RS
.PP
.if t \fB<newline>\fP
.if n \fB<newline>\fP
.RE
.PD
.SH "'SIMPLE COMMANDS ONLY,' SAYS SCARJO SHELL"
.PP
A \fIsimple command\fP is a sequence of optional variable assignments
followed by \fBblank\fP-separated words and redirections, and
terminated by a \fIcontrol operator\fP. The first word
specifies the command to be executed, and is passed as argument zero.
The remaining words are passed as arguments to the invoked command.
.PP
.SH "COMMAND EXECUTION"
After a command has been split into words, if it results in a
simple command and an optional list of arguments, the shell attempts to
locate it. ScarJo Shell searches for it in the list of shell builtins. If a match is found, that
builtin is invoked.
.PP
If the name is a builtin,
.B ScarJo shell
searches each element of the
.SM
.B PATH
for a directory containing an executable file by that name.
.SH ENVIRONMENT
When a program is invoked it is given an array of strings
called the
.IR environment .
This is a list of
\fIname\fP\-\fIvalue\fP pairs, of the form
.IR "name\fR=\fPvalue" .
.PP
The shell provides several ways to manipulate the environment.
On invocation, the shell scans its own environment and
creates a parameter for each name found, automatically marking
it for
.I export
to child processes. Executed commands inherit the environment.
./" .B export
./" and
./" .B declare \-x
./" commands allow parameters and functions to be added to and
./" deleted from the environment. If the value of a parameter
./" in the environment is modified, the new value becomes part
./" of the environment, replacing the old. The environment
./" inherited by any executed command consists of the shell's
./" initial environment, whose values may be modified in the shell,
./" less any pairs removed by the
./" .B unset
./" command, plus any additions via the
./" .B export
./" and
./" .B declare \-x
./" commands.
./" .PP
./" The environment for any
./" .I simple command
./" or function may be augmented temporarily by prefixing it with
./" parameter assignments, as described above in
./" .SM
./" .BR PARAMETERS .
./" These assignment statements affect only the environment seen
./" by that command.
./" .PP
./" If the
./" .B \-k
./" option is set (see the
./" .B set
./" builtin command below), then
./" .I all
./" parameter assignments are placed in the environment for a command,
./" not just those that precede the command name.
./" .PP
./" When
./" .B ScarJo shell
./" invokes an external command, the variable
./" .B _
./" is set to the full filename of the command and passed to that
./" command in its environment.
.SH "EXIT STATUS"
.PP
The exit status of an executed command is the value returned by the
\fIwaitpid\fP system call or equivalent function. Exit statuses
fall between 0 and 255, though, as explained below, the shell may
use values above 125 specially. Exit statuses from shell builtins and
compound commands are also limited to this range. Under certain
circumstances, the shell will use special values to indicate specific
failure modes.
.PP
For the shell's purposes, a command which exits with a
zero exit status has succeeded. An exit status of zero
indicates success. A non-zero exit status indicates failure.
./" When a command terminates on a fatal signal \fIN\fP, \fBScarJo shell\fP uses
./" the value of 128+\fIN\fP as the exit status.
./" .PP
./" If a command is not found, the child process created to
./" execute it returns a status of 127. If a command is found
./" but is not executable, the return status is 126.
./" .PP
./" If a command fails because of an error during expansion or redirection,
./" the exit status is greater than zero.
./" .PP
./" Shell builtin commands return a status of 0 (\fItrue\fP) if
./" successful, and non-zero (\fIfalse\fP) if an error occurs
./" while they execute.
./" All builtins return an exit status of 2 to indicate incorrect usage.
./" .PP
\fBScarJo Shell\fP itself returns the exit status of the last command
executed, unless a syntax error occurs, in which case it exits
with a non-zero value. See also the \fBexit\fP builtin
command below.
./"
.SH SIGNALS
\fBScarJo shell\fP exits when you type C-d.
./" When \fBScarJo shell\fP is interactive, in the absence of any traps, it ignores
./" .SM
./" .B SIGTERM
./" (so that \fBkill 0\fP does not kill an interactive shell),
./" and
./" .SM
./" .B SIGINT
./" is caught and handled (so that the \fBwait\fP builtin is interruptible).
./" In all cases, \fBScarJo shell\fP ignores
./" .SM
./" .BR SIGQUIT .
./" If job control is in effect,
./" .B ScarJo shell
./" ignores
./" .SM
./" .BR SIGTTIN ,
./" .SM
./" .BR SIGTTOU ,
./" and
./" .SM
./" .BR SIGTSTP .
./" .PP
./" Non-builtin commands run by \fBScarJo shell\fP have signal handlers
./" set to the values inherited by the shell from its parent.
./" When job control is not in effect, asynchronous commands
./" ignore
./" .SM
./" .B SIGINT
./" and
./" .SM
./" .B SIGQUIT
./" in addition to these inherited handlers.
./" Commands run as a result of command substitution ignore the
./" keyboard-generated job control signals
./" .SM
./" .BR SIGTTIN ,
./" .SM
./" .BR SIGTTOU ,
./" and
./" .SM
./" .BR SIGTSTP .
./" .PP
./" The shell exits by default upon receipt of a
./" .SM
./" .BR SIGHUP .
./" Before exiting, an interactive shell resends the
./" .SM
./" .B SIGHUP
./" to all jobs, running or stopped.
./" Stopped jobs are sent
./" .SM
./" .B SIGCONT
./" to ensure that they receive the
./" .SM
./" .BR SIGHUP .
./" To prevent the shell from
./" sending the signal to a particular job, it should be removed from the
./" jobs table with the
./" .B disown
./" builtin (see
./" .SM
./" .B "SHELL BUILTIN COMMANDS"
./" below) or marked
./" to not receive
./" .SM
./" .B SIGHUP
./" using
./" .BR "disown \-h" .
./" .PP
./" If the
./" .B huponexit
./" shell option has been set with
./" .BR shopt ,
./" .B ScarJo shell
./" sends a
./" .SM
./" .B SIGHUP
./" to all jobs when an interactive login shell exits.
./" .PP
./" If \fBScarJo shell\fP is waiting for a command to complete and receives a signal
./" for which a trap has been set, the trap will not be executed until
./" the command completes.
./" When \fBScarJo shell\fP is waiting for an asynchronous command via the \fBwait\fP
./" builtin, the reception of a signal for which a trap has been set will
./" cause the \fBwait\fP builtin to return immediately with an exit status
./" greater than 128, immediately after which the trap is executed.
./" .SH "JOB CONTROL"
./" .I Job control
./" refers to the ability to selectively stop (\fIsuspend\fP)
./" the execution of processes and continue (\fIresume\fP)
./" their execution at a later point. A user typically employs
./" this facility via an interactive interface supplied jointly
./" by the operating system kernel's terminal driver and
./" .BR ScarJo shell .
./" .PP
./" The shell associates a
./" .I job
./" with each pipeline. It keeps a table of currently executing
./" jobs, which may be listed with the
./" .B jobs
./" command. When
./" .B ScarJo shell
./" starts a job asynchronously (in the
./" .IR background ),
./" it prints a line that looks like:
./" .RS
./" .PP
./" [1] 25647
./" .RE
./" .PP
./" indicating that this job is job number 1 and that the process ID
./" of the last process in the pipeline associated with this job is 25647.
./" All of the processes in a single pipeline are members of the same job.
./" .B ScarJo Shell
./" uses the
./" .I job
./" abstraction as the basis for job control.
./" .PP
./" To facilitate the implementation of the user interface to job
./" control, the operating system maintains the notion of a \fIcurrent terminal
./" process group ID\fP. Members of this process group (processes whose
./" process group ID is equal to the current terminal process group ID)
./" receive keyboard-generated signals such as
./" .SM
./" .BR SIGINT .
./" These processes are said to be in the
./" .IR foreground .
./" .I Background
./" processes are those whose process group ID differs from the terminal's;
./" such processes are immune to keyboard-generated signals.
./" Only foreground processes are allowed to read from or, if the
./" user so specifies with \f(CWstty tostop\fP, write to the
./" terminal.
./" Background processes which attempt to read from (write to when
./" \f(CWstty tostop\fP is in effect) the
./" terminal are sent a
./" .SM
./" .B SIGTTIN (SIGTTOU)
./" signal by the kernel's terminal driver,
./" which, unless caught, suspends the process.
./" .PP
./" If the operating system on which
./" .B ScarJo shell
./" is running supports
./" job control,
./" .B ScarJo shell
./" contains facilities to use it.
./" Typing the
./" .I suspend
./" character (typically
./" .BR ^Z ,
./" Control-Z) while a process is running
./" causes that process to be stopped and returns control to
./" .BR ScarJo shell .
./" Typing the
./" .I "delayed suspend"
./" character (typically
./" .BR ^Y ,
./" Control-Y) causes the process to be stopped when it
./" attempts to read input from the terminal, and control to
./" be returned to
./" .BR ScarJo shell .
./" The user may then manipulate the state of this job, using the
./" .B bg
./" command to continue it in the background, the
./" .B fg
./" command to continue it in the foreground, or
./" the
./" .B kill
./" command to kill it. A \fB^Z\fP takes effect immediately,
./" and has the additional side effect of causing pending output
./" and typeahead to be discarded.
./" .PP
./" There are a number of ways to refer to a job in the shell.
./" The character
./" .B %
./" introduces a job specification (\fIjobspec\fP). Job number
./" .I n
./" may be referred to as
./" .BR %n .
./" A job may also be referred to using a prefix of the name used to
./" start it, or using a substring that appears in its command line.
./" For example,
./" .B %ce
./" refers to a stopped
./" .B ce
./" job. If a prefix matches more than one job,
./" .B ScarJo shell
./" reports an error. Using
./" .BR %?ce ,
./" on the other hand, refers to any job containing the string
./" .B ce
./" in its command line. If the substring matches more than one job,
./" .B ScarJo shell
./" reports an error. The symbols
./" .B %%
./" and
./" .B %+
./" refer to the shell's notion of the
./" .IR "current job" ,
./" which is the last job stopped while it was in
./" the foreground or started in the background.
./" The
./" .I "previous job"
./" may be referenced using
./" .BR %\- .
./" If there is only a single job, \fB%+\fP and \fB%\-\fP can both be used
./" to refer to that job.
./" In output pertaining to jobs (e.g., the output of the
./" .B jobs
./" command), the current job is always flagged with a
./" .BR + ,
./" and the previous job with a
./" .BR \- .
./" A single % (with no accompanying job specification) also refers to the
./" current job.
./" .PP
./" Simply naming a job can be used to bring it into the
./" foreground:
./" .B %1
./" is a synonym for
./" \fB``fg %1''\fP,
./" bringing job 1 from the background into the foreground.
./" Similarly,
./" .B ``%1 &''
./" resumes job 1 in the background, equivalent to
./" \fB``bg %1''\fP.
./" .PP
./" The shell learns immediately whenever a job changes state.
./" Normally,
./" .B ScarJo shell
./" waits until it is about to print a prompt before reporting
./" changes in a job's status so as to not interrupt
./" any other output. If the
./" .B \-b
./" option to the
./" .B set
./" builtin command
./" is enabled,
./" .B ScarJo shell
./" reports such changes immediately.
./" Any trap on
./" .SM
./" .B SIGCHLD
./" is executed for each child that exits.
./" .PP
./" If an attempt to exit
./" .B ScarJo shell
./" is made while jobs are stopped (or, if the \fBcheckjobs\fP shell option has
./" been enabled using the \fBshopt\fP builtin, running), the shell prints a
./" warning message, and, if the \fBcheckjobs\fP option is enabled, lists the
./" jobs and their statuses.
./" The
./" .B jobs
./" command may then be used to inspect their status.
./" If a second attempt to exit is made without an intervening command,
./" the shell does not print another warning, and any stopped
./" jobs are terminated.
.SH "SHELL BUILTIN COMMANDS"
.\" start of ScarJo shell_builtins
.zZ
.PP
./" Unless otherwise noted, each builtin command documented in this
./" section as accepting options preceded by
./" .B \-
./" accepts
./" .B \-\-
./" to signify the end of the options.
./" The \fB:\fP, \fBtrue\fP, \fBfalse\fP, and \fBtest\fP builtins
./" do not accept options and do not treat \fB\-\-\fP specially.
./" The \fBexit\fP, \fBlogout\fP, \fBbreak\fP, \fBcontinue\fP, \fBlet\fP,
./" and \fBshift\fP builtins accept and process arguments beginning with
./" \fB\-\fP without requiring \fB\-\-\fP.
./" Other builtins that accept arguments but are not specified as accepting
./" options interpret arguments beginning with \fB\-\fP as invalid options and
./" require \fB\-\-\fP to prevent this interpretation.
.sp .5
.PD 0
.TP
\fBexit\fP [\fIn\fP]
Cause the shell to exit
with a status of \fIn\fP. If
.I n
is omitted, the exit status
is that of the last command executed.
A trap on
.SM
.B EXIT
is executed before the shell terminates.
./" .TP
./" \fBfg\fP [\fIjobspec\fP]
./" Resume
./" .I jobspec
./" in the foreground, and make it the current job.
./" If
./" .I jobspec
./" is not present, the shell's notion of the \fIcurrent job\fP is used.
./" The return value is that of the command placed into the foreground,
./" or failure if run when job control is disabled or, when run with
./" job control enabled, if
./" .I jobspec
./" does not specify a valid job or
./" .I jobspec
./" specifies a job that was started without job control.
./"
./".TP
./" \fBsetenv\fP [\fB\-\-abefhkmnptuvxBCEHPT\fP] [\fB\-o\fP \fIoption\-name\fP] [\fIarg\fP ...]
./" .PD 0
./" .TP
./" \fBset\fP [\fB+abefhkmnptuvxBCEHPT\fP] [\fB+o\fP \fIoption\-name\fP] [\fIarg\fP ...]
.TP
\fBenv\fP
Prints a list of the environment variables.
.TP
\fBsetenv\fP [\fIname\fP \fIvalue\fP]
Adds a new environment variable or changes an existing variable.
.TP
\fBunsetenv\fP [\fIname\fP \fIvalue\fP]
Unsets an environment variable.
./" .PD 0
./" .PD 0
./" .TP
./" .PD
./" Without options, the name and value of each shell variable are displayed
./" in a format that can be reused as input
./" for setting or resetting the currently-set variables.
./" Read-only variables cannot be reset.
./" In \fIposix\fP mode, only shell variables are listed.
./" The output is sorted according to the current locale.
./" When options are specified, they set or unset shell attributes.
./" Any arguments remaining after option processing are treated
./" as values for the positional parameters and are assigned, in order, to
./" .BR $1 ,
./" .BR $2 ,
./" .B ...
./" .BR $\fIn\fP .
./" Options, if specified, have the following meanings:
./" .RS
./" .PD 0
./" .TP 8
./" .B \-a
./" Automatically mark variables and functions which are modified or
./" created for export to the environment of subsequent commands.
./" .TP 8
./" .B \-b
./" Report the status of terminated background jobs
./" immediately, rather than before the next primary prompt. This is
./" effective only when job control is enabled.
./" .TP 8
./" .B \-e
./" Exit immediately if a
./" \fIpipeline\fP (which may consist of a single \fIsimple command\fP),
./" a \fIlist\fP,
./" or a \fIcompound command\fP
./" (see
./" .SM
./" .B SHELL GRAMMAR
./" above), exits with a non-zero status.
./" The shell does not exit if the
./" command that fails is part of the command list immediately following a
./" .B while
./" or
./" .B until
./" keyword,
./" part of the test following the
./" .B if
./" or
./" .B elif
./" reserved words, part of any command executed in a
./" .B &&
./" or
./" .B ||
./" list except the command following the final \fB&&\fP or \fB||\fP,
./" any command in a pipeline but the last,
./" or if the command's return value is
./" being inverted with
./" .BR ! .
./" If a compound command other than a subshell
./" returns a non-zero status because a command failed
./" while \fB\-e\fP was being ignored, the shell does not exit.
./" A trap on \fBERR\fP, if set, is executed before the shell exits.
./" This option applies to the shell environment and each subshell environment
./" separately (see
./" .SM
./" .B "COMMAND EXECUTION ENVIRONMENT"
./" above), and may cause
./" subshells to exit before executing all the commands in the subshell.
./" .if t .sp 0.5
./" .if n .sp 1
./" If a compound command or shell function executes in a context
./" where \fB\-e\fP is being ignored,
./" none of the commands executed within the compound command or function body
./" will be affected by the \fB\-e\fP setting, even if \fB\-e\fP is set
./" and a command returns a failure status.
./" If a compound command or shell function sets \fB\-e\fP while executing in
./" a context where \fB\-e\fP is ignored, that setting will not have any
./" effect until the compound command or the command containing the function
./" call completes.
./" .TP 8
./" .B \-f
./" Disable pathname expansion.
./" .TP 8
./" .B \-h
./" Remember the location of commands as they are looked up for execution.
./" This is enabled by default.
./" .TP 8
./" .B \-k
./" All arguments in the form of assignment statements
./" are placed in the environment for a command, not just
./" those that precede the command name.
./" .TP 8
./" .B \-m
./" Monitor mode. Job control is enabled. This option is on
./" by default for interactive shells on systems that support
./" it (see
./" .SM
./" .B JOB CONTROL
./" above).
./" All processes run in a separate process group.
./" When a background job completes, the shell prints a line
./" containing its exit status.
./" .TP 8
./" .B \-n
./" Read commands but do not execute them. This may be used to
./" check a shell script for syntax errors. This is ignored by
./" interactive shells.
./" .TP 8
./" .B \-o \fIoption\-name\fP
./" The \fIoption\-name\fP can be one of the following:
./" .RS
./" .TP 8
./" .B allexport
./" Same as
./" .BR \-a .
./" .TP 8
./" .B braceexpand
./" Same as
./" .BR \-B .
./" .TP 8
./" .B emacs
./" Use an emacs-style command line editing interface. This is enabled
./" by default when the shell is interactive, unless the shell is started
./" with the
./" .B \-\-noediting
./" option.
./" This also affects the editing interface used for \fBread \-e\fP.
./" .TP 8
./" .B errexit
./" Same as
./" .BR \-e .
./" .TP 8
./" .B errtrace
./" Same as
./" .BR \-E .
./" .TP 8
./" .B functrace
./" Same as
./" .BR \-T .
./" .TP 8
./" .B hashall
./" Same as
./" .BR \-h .
./" .TP 8
./" .B histexpand
./" Same as
./" .BR \-H .
./" .TP 8
./" .B history
./" Enable command history, as described above under
./" .SM
./" .BR HISTORY .
./" This option is on by default in interactive shells.
./" .TP 8
./" .B ignoreeof
./" The effect is as if the shell command
./" .if t \f(CWIGNOREEOF=10\fP
./" .if n ``IGNOREEOF=10''
./" had been executed
./" (see
./" .B Shell Variables
./" above).
./" .TP 8
./" .B keyword
./" Same as
./" .BR \-k .
./" .TP 8
./" .B monitor
./" Same as
./" .BR \-m .
./" .TP 8
./" .B noclobber
./" Same as
./" .BR \-C .
./" .TP 8
./" .B noexec
./" Same as
./" .BR \-n .
./" .TP 8
./" .B noglob
./" Same as
./" .BR \-f .
./" .TP 8
./" .B nolog
./" Currently ignored.
./" .TP 8
./" .B notify
./" Same as
./" .BR \-b .
./" .TP 8
./" .B nounset
./" Same as
./" .BR \-u .
./" .TP 8
./" .B onecmd
./" Same as
./" .BR \-t .
./" .TP 8
./" .B physical
./" Same as
./" .BR \-P .
./" .TP 8
./" .B pipefail
./" If set, the return value of a pipeline is the value of the last
./" (rightmost) command to exit with a non-zero status, or zero if all
./" commands in the pipeline exit successfully.
./" This option is disabled by default.
./" .TP 8
./" .B posix
./" Change the behavior of
./" .B bash
./" where the default operation differs
./" from the POSIX standard to match the standard (\fIposix mode\fP).
./" See
./" .SM
./" .B "SEE ALSO"
./" below for a reference to a document that details how posix mode affects
./" bash's behavior.
./" .TP 8
./" .B privileged
./" Same as
./" .BR \-p .
./" .TP 8
./" .B verbose
./" Same as
./" .BR \-v .
./" .TP 8
./" .B vi
./" Use a vi-style command line editing interface.
./" This also affects the editing interface used for \fBread \-e\fP.
./" .TP 8
./" .B xtrace
./" Same as
./" .BR \-x .
./" .sp .5
./" .PP
./" If
./" .B \-o
./" is supplied with no \fIoption\-name\fP, the values of the current options are
./" printed.
./" If
./" .B +o
./" is supplied with no \fIoption\-name\fP, a series of
./" .B set
./" commands to recreate the current option settings is displayed on
./" the standard output.
./" .RE
./" .TP 8
./" .B \-p
./" Turn on
./" .I privileged
./" mode. In this mode, the
./" .SM
./" .B $ENV
./" and
./" .SM
./" .B $BASH_ENV
./" files are not processed, shell functions are not inherited from the
./" environment, and the
./" .SM
./" .BR SHELLOPTS ,
./" .SM
./" .BR BASHOPTS ,
./" .SM
./" .BR CDPATH ,
./" and
./" .SM
./" .B GLOBIGNORE
./" variables, if they appear in the environment, are ignored.
./" If the shell is started with the effective user (group) id not equal to the
./" real user (group) id, and the \fB\-p\fP option is not supplied, these actions
./" are taken and the effective user id is set to the real user id.
./" If the \fB\-p\fP option is supplied at startup, the effective user id is
./" not reset.
./" Turning this option off causes the effective user
./" and group ids to be set to the real user and group ids.
./" .TP 8
./" .B \-t
./" Exit after reading and executing one command.
./" .TP 8
./" .B \-u
./" Treat unset variables and parameters other than the special
./" parameters "@" and "*" as an error when performing
./" parameter expansion. If expansion is attempted on an
./" unset variable or parameter, the shell prints an error message, and,
./" if not interactive, exits with a non-zero status.
./" .TP 8
./" .B \-v
./" Print shell input lines as they are read.
./" .TP 8
./" .B \-x
./" After expanding each \fIsimple command\fP,
./" \fBfor\fP command, \fBcase\fP command, \fBselect\fP command, or
./" arithmetic \fBfor\fP command, display the expanded value of
./" .SM
./" .BR PS4 ,
./" followed by the command and its expanded arguments
./" or associated word list.
./" .TP 8
./" .B \-B
./" The shell performs brace expansion (see
./" .B Brace Expansion
./" above). This is on by default.
./" .TP 8
./" .B \-C
./" If set,
./" .B bash
./" does not overwrite an existing file with the
./" .BR > ,
./" .BR >& ,
./" and
./" .B <>
./" redirection operators. This may be overridden when
./" creating output files by using the redirection operator
./" .B >|
./" instead of
./" .BR > .
./" .TP 8
./" .B \-E
./" If set, any trap on \fBERR\fP is inherited by shell functions, command
./" substitutions, and commands executed in a subshell environment.
./" The \fBERR\fP trap is normally not inherited in such cases.
./" .TP 8
./" .B \-H
./" Enable
./" .B !
./" style history substitution. This option is on by
./" default when the shell is interactive.
./" .TP 8
./" .B \-P
./" If set, the shell does not resolve symbolic links when executing
./" commands such as
./" .B cd
./" that change the current working directory. It uses the
./" physical directory structure instead. By default,
./" .B bash
./" follows the logical chain of directories when performing commands
./" which change the current directory.
./" .TP 8
./" .B \-T
./" If set, any traps on \fBDEBUG\fP and \fBRETURN\fP are inherited by shell
./" functions, command substitutions, and commands executed in a
./" subshell environment.
./" The \fBDEBUG\fP and \fBRETURN\fP traps are normally not inherited
./" in such cases.
./" .TP 8
./" .B \-\-
./" If no arguments follow this option, then the positional parameters are
./" unset. Otherwise, the positional parameters are set to the
./" \fIarg\fPs, even if some of them begin with a
./" .BR \- .
./" .TP 8
./" .B \-
./" Signal the end of options, cause all remaining \fIarg\fPs to be
./" assigned to the positional parameters. The
./" .B \-x
./" and
./" .B \-v
./" options are turned off.
./" If there are no \fIarg\fPs,
./" the positional parameters remain unchanged.
./" .PD
./" .PP
./" The options are off by default unless otherwise noted.
./" Using + rather than \- causes these options to be turned off.
./" The options can also be specified as arguments to an invocation of
./" the shell.
./" The current set of options may be found in
./" .BR $\- .
./" The return status is always true unless an invalid option is encountered.
./" .RE
./" .TP
./" ./" \fBshift\fP [\fIn\fP]
./" The positional parameters from \fIn\fP+1 ... are renamed to
./" .B $1
./" .B ....
./" Parameters represented by the numbers \fB$#\fP
./" down to \fB$#\fP\-\fIn\fP+1 are unset.
./" .I n
./" must be a non-negative number less than or equal to \fB$#\fP.
./" If
./" .I n
./" is 0, no parameters are changed.
./" If
./" .I n
./" is not given, it is assumed to be 1.
./" If
./" .I n
./" is greater than \fB$#\fP, the positional parameters are not changed.
./" The return status is greater than zero if
./" .I n
./" is greater than
./" .B $#
./" or less than zero; otherwise 0.
./" .TP
./" \fBshopt\fP [\fB\-pqsu\fP] [\fB\-o\fP] [\fIoptname\fP ...]
./" Toggle the values of settings controlling optional shell behavior.
./" The settings can be either those listed below, or, if the
./" .B \-o
./" option is used, those available with the
./" .B \-o
./" option to the \fBset\fP builtin command.
./" With no options, or with the
./" .B \-p
./" option, a list of all settable options is displayed, with
./" an indication of whether or not each is set.
./" The \fB\-p\fP option causes output to be displayed in a form that
./" may be reused as input.
./" Other options have the following meanings:
./" .RS
./" .PD 0
./" .TP
./" .B \-s
./" Enable (set) each \fIoptname\fP.
./" .TP
./" .B \-u
./" Disable (unset) each \fIoptname\fP.
./" .TP
./" .B \-q
./" Suppresses normal output (quiet mode); the return status indicates
./" whether the \fIoptname\fP is set or unset.
./" If multiple \fIoptname\fP arguments are given with
./" .BR \-q ,
./" the return status is zero if all \fIoptnames\fP are enabled; non-zero
./" otherwise.
./" .TP
./" .B \-o
./" Restricts the values of \fIoptname\fP to be those defined for the
./" .B \-o
./" option to the
./" .B set
./" builtin.
./" .PD
./" .PP
./" If either
./" .B \-s
./" or
./" .B \-u
./" is used with no \fIoptname\fP arguments,
./" .B shopt
./" shows only those options which are set or unset, respectively.
./" Unless otherwise noted, the \fBshopt\fP options are disabled (unset)
./" by default.
./" .PP
./" The return status when listing options is zero if all \fIoptnames\fP
./" are enabled, non-zero otherwise. When setting or unsetting options,
./" the return status is zero unless an \fIoptname\fP is not a valid shell
./" option.
./" .PP
./" The list of \fBshopt\fP options is:
./" .if t .sp .5v
./" .if n .sp 1v
./" .PD 0
./" .TP 8
./" .B autocd
./" If set, a command name that is the name of a directory is executed as if
./" it were the argument to the \fBcd\fP command.
./" This option is only used by interactive shells.
./" .TP 8
./" .B cdable_vars
./" If set, an argument to the
./" .B cd
./" builtin command that
./" is not a directory is assumed to be the name of a variable whose
./" value is the directory to change to.
./" .TP 8
./" .B cdspell
./" If set, minor errors in the spelling of a directory component in a
./" .B cd
./" command will be corrected.
./" The errors checked for are transposed characters,
./" a missing character, and one character too many.
./" If a correction is found, the corrected filename is printed,
./" and the command proceeds.
./" This option is only used by interactive shells.
./" .TP 8
./" .B checkhash
./" If set, \fBbash\fP checks that a command found in the hash
./" table exists before trying to execute it. If a hashed command no
./" longer exists, a normal path search is performed.
./" .TP 8
./" .B checkjobs
./" If set, \fBbash\fP lists the status of any stopped and running jobs before
./" exiting an interactive shell. If any jobs are running, this causes
./" the exit to be deferred until a second exit is attempted without an
./" intervening command (see
./" .SM
./" .B "JOB CONTROL"
./" above). The shell always
./" postpones exiting if any jobs are stopped.
./" .TP 8
./" .B checkwinsize
./" If set, \fBbash\fP checks the window size after each command
./" and, if necessary, updates the values of
./" .SM
./" .B LINES
./" and
./" .SM
./" .BR COLUMNS .
./" .TP 8
./" .B cmdhist
./" If set,
./" .B bash
./" attempts to save all lines of a multiple-line
./" command in the same history entry. This allows
./" easy re-editing of multi-line commands.
./" .TP 8
./" .B compat31
./" If set,
./" .B bash
./" changes its behavior to that of version 3.1 with respect to quoted
./" arguments to the \fB[[\fP conditional command's \fB=~\fP operator
./" and locale-specific string comparison when using the \fB[[\fP
./" conditional command's \fB<\fP and \fB>\fP operators.
./" Bash versions prior to bash-4.1 use ASCII collation and