| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | .\" $NetBSD: sh.1,v 1.119 2016/02/24 15:28:36 wiz Exp $ | | 1 | .\" $NetBSD: sh.1,v 1.120 2016/03/31 16:18:22 christos Exp $ |
2 | .\" Copyright (c) 1991, 1993 | | 2 | .\" Copyright (c) 1991, 1993 |
3 | .\" The Regents of the University of California. All rights reserved. | | 3 | .\" The Regents of the University of California. All rights reserved. |
4 | .\" | | 4 | .\" |
5 | .\" This code is derived from software contributed to Berkeley by | | 5 | .\" This code is derived from software contributed to Berkeley by |
6 | .\" Kenneth Almquist. | | 6 | .\" Kenneth Almquist. |
7 | .\" | | 7 | .\" |
8 | .\" Redistribution and use in source and binary forms, with or without | | 8 | .\" Redistribution and use in source and binary forms, with or without |
9 | .\" modification, are permitted provided that the following conditions | | 9 | .\" modification, are permitted provided that the following conditions |
10 | .\" are met: | | 10 | .\" are met: |
11 | .\" 1. Redistributions of source code must retain the above copyright | | 11 | .\" 1. Redistributions of source code must retain the above copyright |
12 | .\" notice, this list of conditions and the following disclaimer. | | 12 | .\" notice, this list of conditions and the following disclaimer. |
13 | .\" 2. Redistributions in binary form must reproduce the above copyright | | 13 | .\" 2. Redistributions in binary form must reproduce the above copyright |
14 | .\" notice, this list of conditions and the following disclaimer in the | | 14 | .\" notice, this list of conditions and the following disclaimer in the |
| @@ -21,27 +21,27 @@ | | | @@ -21,27 +21,27 @@ |
21 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | | 21 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
22 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | 22 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
23 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | | 23 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
24 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 24 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
25 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 25 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
26 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 26 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
27 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 27 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
28 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 28 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
29 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 29 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
30 | .\" SUCH DAMAGE. | | 30 | .\" SUCH DAMAGE. |
31 | .\" | | 31 | .\" |
32 | .\" @(#)sh.1 8.6 (Berkeley) 5/4/95 | | 32 | .\" @(#)sh.1 8.6 (Berkeley) 5/4/95 |
33 | .\" | | 33 | .\" |
34 | .Dd January 5, 2015 | | 34 | .Dd March 31, 2016 |
35 | .Dt SH 1 | | 35 | .Dt SH 1 |
36 | .ds flags abCEeFfhnuvxIimpqV | | 36 | .ds flags abCEeFfhnuvxIimpqV |
37 | .Os | | 37 | .Os |
38 | .Sh NAME | | 38 | .Sh NAME |
39 | .Nm sh | | 39 | .Nm sh |
40 | .Nd command interpreter (shell) | | 40 | .Nd command interpreter (shell) |
41 | .Sh SYNOPSIS | | 41 | .Sh SYNOPSIS |
42 | .Nm | | 42 | .Nm |
43 | .Bk -words | | 43 | .Bk -words |
44 | .Op Fl \*[flags] | | 44 | .Op Fl \*[flags] |
45 | .Op Cm +\*[flags] | | 45 | .Op Cm +\*[flags] |
46 | .Ek | | 46 | .Ek |
47 | .Bk -words | | 47 | .Bk -words |
| @@ -320,48 +320,66 @@ instead of attempting | | | @@ -320,48 +320,66 @@ instead of attempting |
320 | .Xr vfork 2 | | 320 | .Xr vfork 2 |
321 | when it needs to create a new process. | | 321 | when it needs to create a new process. |
322 | This should normally have no visible effect, | | 322 | This should normally have no visible effect, |
323 | but can slow execution. | | 323 | but can slow execution. |
324 | The | | 324 | The |
325 | .Nm | | 325 | .Nm |
326 | can be compiled to always use | | 326 | can be compiled to always use |
327 | .Xr fork 2 | | 327 | .Xr fork 2 |
328 | in which case altering the | | 328 | in which case altering the |
329 | .Fl F | | 329 | .Fl F |
330 | flag has no effect. | | 330 | flag has no effect. |
331 | .It Fl h Em trackall | | 331 | .It Fl h Em trackall |
332 | Bind commands in functions to file system paths when the function is defined. | | 332 | Bind commands in functions to file system paths when the function is defined. |
| | | 333 | .\" They can seek me here (that dreaded filesystem) |
333 | When off, | | 334 | When off, |
334 | the file system is searched for commands each time the function is invoked. | | 335 | the file system is searched for commands each time the function is invoked. |
335 | (Not implemented.) | | 336 | (Not implemented.) |
| | | 337 | .\" then can seek me there (the filesystem, once again) |
336 | .It Fl p Em nopriv | | 338 | .It Fl p Em nopriv |
337 | Do not attempt to reset effective uid if it does not match uid. | | 339 | Do not attempt to reset effective uid if it does not match uid. |
338 | This is not set by default to help avoid incorrect usage by setuid | | 340 | This is not set by default to help avoid incorrect usage by setuid |
339 | root programs via | | 341 | root programs via |
340 | .Xr system 3 | | 342 | .Xr system 3 |
341 | or | | 343 | or |
342 | .Xr popen 3 . | | 344 | .Xr popen 3 . |
343 | .It "\ \ " Em cdprint | | 345 | .It "\ \ " Em cdprint |
344 | Make an interactive shell always print the new directory name when | | 346 | Make an interactive shell always print the new directory name when |
345 | changed by the | | 347 | changed by the |
346 | .Ic cd | | 348 | .Ic cd |
347 | command. | | 349 | command. |
348 | .It "\ \ " Em nolog | | 350 | .It "\ \ " Em nolog |
349 | Prevent the entry of function definitions into the command history (see | | 351 | Prevent the entry of function definitions into the command history (see |
350 | .Ic fc | | 352 | .Ic fc |
351 | in the | | 353 | in the |
352 | .Sx Built-ins | | 354 | .Sx Built-ins |
353 | section.) | | 355 | section.) |
354 | (Not implemented.) | | 356 | (Not implemented.) |
| | | 357 | .It "\ \ " Em posix |
| | | 358 | Enables closer adherence to the shell standard. |
| | | 359 | This option will default set at shell startup if the |
| | | 360 | environment variable |
| | | 361 | .Ev POSIXLY_CORRECT |
| | | 362 | is present. |
| | | 363 | That can be overridden by the |
| | | 364 | .Fl o |
| | | 365 | option on the command line. |
| | | 366 | Currently this option controls whether (!posix) or not (posix) |
| | | 367 | the file given by the |
| | | 368 | .Ev ENV |
| | | 369 | variable is read at startup by a non-interactive shell. |
| | | 370 | Consequently, while it can be manipulated by the |
| | | 371 | .Ic set |
| | | 372 | command, doing so has no current purpose. |
355 | .It "\ \ " Em tabcomplete | | 373 | .It "\ \ " Em tabcomplete |
356 | Enables filename completion in the command line editor. | | 374 | Enables filename completion in the command line editor. |
357 | Typing a tab character will extend the current input word to match a | | 375 | Typing a tab character will extend the current input word to match a |
358 | filename. | | 376 | filename. |
359 | If more than one filename matches it is only extended to be the common prefix. | | 377 | If more than one filename matches it is only extended to be the common prefix. |
360 | Typing a second tab character will list all the matching names. | | 378 | Typing a second tab character will list all the matching names. |
361 | One of the editing modes, either | | 379 | One of the editing modes, either |
362 | .Fl E | | 380 | .Fl E |
363 | or | | 381 | or |
364 | .Fl V , | | 382 | .Fl V , |
365 | must be enabled for this to work. | | 383 | must be enabled for this to work. |
366 | .El | | 384 | .El |
367 | .Ss Lexical Structure | | 385 | .Ss Lexical Structure |
| @@ -518,62 +536,70 @@ Close standard output (or n). | | | @@ -518,62 +536,70 @@ Close standard output (or n). |
518 | .It [n] Ns \*[Lt]\*[Gt] file | | 536 | .It [n] Ns \*[Lt]\*[Gt] file |
519 | Open file for reading and writing on standard input (or n). | | 537 | Open file for reading and writing on standard input (or n). |
520 | .El | | 538 | .El |
521 | .Pp | | 539 | .Pp |
522 | The following redirection is often called a | | 540 | The following redirection is often called a |
523 | .Dq here-document . | | 541 | .Dq here-document . |
524 | .Bl -item -offset indent | | 542 | .Bl -item -offset indent |
525 | .It | | 543 | .It |
526 | .Li [n]\*[Lt]\*[Lt] delimiter | | 544 | .Li [n]\*[Lt]\*[Lt] delimiter |
527 | .Dl here-doc-text ... | | 545 | .Dl here-doc-text ... |
528 | .Li delimiter | | 546 | .Li delimiter |
529 | .El | | 547 | .El |
530 | .Pp | | 548 | .Pp |
531 | All the text on successive lines up to the delimiter, or to an EOF, is | | 549 | All the text on successive lines up to the delimiter, |
| | | 550 | which must appear on a line by itself, with nothing other |
| | | 551 | than an immediately following newline, is |
532 | saved away and made available to the command on standard input, or file | | 552 | saved away and made available to the command on standard input, or file |
533 | descriptor n if it is specified. | | 553 | descriptor n if it is specified. |
534 | If the delimiter as specified on the initial line is | | 554 | If the delimiter as specified on the initial line is |
535 | quoted, then the here-doc-text is treated literally; otherwise, the text is | | 555 | quoted, then the here-doc-text is treated literally; otherwise, the text is |
536 | subjected to parameter expansion, command substitution, and arithmetic | | 556 | subjected to parameter expansion, command substitution, and arithmetic |
537 | expansion as described in the | | 557 | expansion as described in the |
538 | .Sx Word Expansions | | 558 | .Sx Word Expansions |
539 | section below. | | 559 | section below. |
540 | If the operator is | | 560 | If the operator is |
541 | .Dq \*[Lt]\*[Lt]- | | 561 | .Dq \*[Lt]\*[Lt]\(mi |
542 | instead of | | 562 | instead of |
543 | .Dq \*[Lt]\*[Lt] , | | 563 | .Dq \*[Lt]\*[Lt] , |
544 | then leading tabs in the here-doc-text are stripped. | | 564 | then leading tabs in all lines in the here-doc-text, including before the |
| | | 565 | end delimiter, are stripped. |
| | | 566 | If the delimiter is not quoted, lines in here-doc-text that end with |
| | | 567 | an unquoted \e are joined to the following line, the \e and following |
| | | 568 | newline are simply removed while reading the here-doc, which thus guarantees |
| | | 569 | that neither of those lines can be the end delimiter. |
545 | .Ss Search and Execution | | 570 | .Ss Search and Execution |
546 | There are three types of commands: shell functions, built-in commands, and | | 571 | There are three types of commands: shell functions, built-in commands, and |
547 | normal programs -- and the command is searched for (by name) in that order. | | 572 | normal programs -- and the command is searched for (by name) in that order. |
548 | They each are executed in a different way. | | 573 | They each are executed in a different way. |
549 | .Pp | | 574 | .Pp |
550 | When a shell function is executed, all of the shell positional parameters | | 575 | When a shell function is executed, all of the shell positional parameters |
551 | (except $0, which remains unchanged) are set to the arguments of the shell | | 576 | (except $0, which remains unchanged) are set to the arguments of the shell |
552 | function. | | 577 | function. |
553 | The variables which are explicitly placed in the environment of | | 578 | The variables which are explicitly placed in the environment of |
554 | the command (by placing assignments to them before the function name) are | | 579 | the command (by placing assignments to them before the function name) are |
555 | made local to the function and are set to the values given. | | 580 | made local to the function and are set to the values given. |
556 | Then the command given in the function definition is executed. | | 581 | Then the command given in the function definition is executed. |
557 | The positional parameters are restored to their original values | | 582 | The positional parameters are restored to their original values |
558 | when the command completes. | | 583 | when the command completes. |
559 | This all occurs within the current shell. | | 584 | This all occurs within the current shell. |
560 | .Pp | | 585 | .Pp |
561 | Shell built-ins are executed internally to the shell, without spawning a | | 586 | Shell built-ins are executed internally to the shell, without spawning a |
562 | new process. | | 587 | new process. |
563 | .Pp | | 588 | .Pp |
564 | Otherwise, if the command name doesn't match a function or built-in, the | | 589 | Otherwise, if the command name doesn't match a function or built-in, the |
565 | command is searched for as a normal program in the file system (as | | 590 | command is searched for as a normal program in the file system (as |
566 | described in the next section). | | 591 | described in the next section). |
| | | 592 | .\" But the damned elusive filesystem shall never be defeated! |
567 | When a normal program is executed, the shell runs the program, | | 593 | When a normal program is executed, the shell runs the program, |
568 | passing the arguments and the environment to the program. | | 594 | passing the arguments and the environment to the program. |
569 | If the program is not a normal executable file (i.e., if it does | | 595 | If the program is not a normal executable file (i.e., if it does |
570 | not begin with the "magic number" whose | | 596 | not begin with the "magic number" whose |
571 | .Tn ASCII | | 597 | .Tn ASCII |
572 | representation is "#!", so | | 598 | representation is "#!", so |
573 | .Xr execve 2 | | 599 | .Xr execve 2 |
574 | returns | | 600 | returns |
575 | .Er ENOEXEC | | 601 | .Er ENOEXEC |
576 | then) the shell will interpret the program in a subshell. | | 602 | then) the shell will interpret the program in a subshell. |
577 | The child shell will reinitialize itself in this case, | | 603 | The child shell will reinitialize itself in this case, |
578 | so that the effect will be as if a | | 604 | so that the effect will be as if a |
579 | new shell had been invoked to handle the ad-hoc shell script, except that | | 605 | new shell had been invoked to handle the ad-hoc shell script, except that |
| @@ -687,33 +713,38 @@ it executes in the current shell -- but | | | @@ -687,33 +713,38 @@ it executes in the current shell -- but |
687 | environment is wiped). | | 713 | environment is wiped). |
688 | .Ss Background Commands -- \*[Am] | | 714 | .Ss Background Commands -- \*[Am] |
689 | If a command is terminated by the control operator ampersand (\*[Am]), the | | 715 | If a command is terminated by the control operator ampersand (\*[Am]), the |
690 | shell executes the command asynchronously -- that is, the shell does not | | 716 | shell executes the command asynchronously -- that is, the shell does not |
691 | wait for the command to finish before executing the next command. | | 717 | wait for the command to finish before executing the next command. |
692 | .Pp | | 718 | .Pp |
693 | The format for running a command in background is: | | 719 | The format for running a command in background is: |
694 | .Pp | | 720 | .Pp |
695 | .Dl command1 \*[Am] [command2 \*[Am] ...] | | 721 | .Dl command1 \*[Am] [command2 \*[Am] ...] |
696 | .Pp | | 722 | .Pp |
697 | If the shell is not interactive, the standard input of an asynchronous | | 723 | If the shell is not interactive, the standard input of an asynchronous |
698 | command is set to | | 724 | command is set to |
699 | .Pa /dev/null . | | 725 | .Pa /dev/null . |
| | | 726 | The process identifier of the most recent command started in the |
| | | 727 | background can be obtained from the value of the special parameter |
| | | 728 | .Dq \&! |
| | | 729 | (see |
| | | 730 | .Sx Special Parameters ) . |
700 | .Ss Lists -- Generally Speaking | | 731 | .Ss Lists -- Generally Speaking |
701 | A list is a sequence of zero or more commands separated by newlines, | | 732 | A list is a sequence of zero or more commands separated by newlines, |
702 | semicolons, or ampersands, and optionally terminated by one of these three | | 733 | semicolons, or ampersands, and optionally terminated by one of these three |
703 | characters. | | 734 | characters. |
704 | The commands in a list are executed in the order they are written. | | 735 | The commands in a list are executed in the order they are written. |
705 | If command is followed by an ampersand, the shell starts the | | 736 | If command is followed by an ampersand, the shell starts the |
706 | command and immediately proceed onto the next command; otherwise it waits | | 737 | command and immediately proceeds to the next command; otherwise it waits |
707 | for the command to terminate before proceeding to the next one. | | 738 | for the command to terminate before proceeding to the next one. |
708 | .Ss Short-Circuit List Operators | | 739 | .Ss Short-Circuit List Operators |
709 | .Dq \*[Am]\*[Am] | | 740 | .Dq \*[Am]\*[Am] |
710 | and | | 741 | and |
711 | .Dq || | | 742 | .Dq || |
712 | are AND-OR list operators. | | 743 | are AND-OR list operators. |
713 | .Dq \*[Am]\*[Am] | | 744 | .Dq \*[Am]\*[Am] |
714 | executes the first command, and then executes the second command if and only | | 745 | executes the first command, and then executes the second command if and only |
715 | if the exit status of the first command is zero. | | 746 | if the exit status of the first command is zero. |
716 | .Dq || | | 747 | .Dq || |
717 | is similar, but executes the second command if and only if the exit status | | 748 | is similar, but executes the second command if and only if the exit status |
718 | of the first command is nonzero. | | 749 | of the first command is nonzero. |
719 | .Dq \*[Am]\*[Am] | | 750 | .Dq \*[Am]\*[Am] |
| @@ -750,37 +781,39 @@ The syntax of the while command is | | | @@ -750,37 +781,39 @@ The syntax of the while command is |
750 | while list | | 781 | while list |
751 | do list | | 782 | do list |
752 | done | | 783 | done |
753 | .Ed | | 784 | .Ed |
754 | .Pp | | 785 | .Pp |
755 | The two lists are executed repeatedly while the exit status of the | | 786 | The two lists are executed repeatedly while the exit status of the |
756 | first list is zero. | | 787 | first list is zero. |
757 | The until command is similar, but has the word | | 788 | The until command is similar, but has the word |
758 | until in place of while, which causes it to | | 789 | until in place of while, which causes it to |
759 | repeat until the exit status of the first list is zero. | | 790 | repeat until the exit status of the first list is zero. |
760 | .Pp | | 791 | .Pp |
761 | The syntax of the for command is | | 792 | The syntax of the for command is |
762 | .Bd -literal -offset indent | | 793 | .Bd -literal -offset indent |
763 | for variable in word ... | | 794 | for variable [ in word ... ] |
764 | do list | | 795 | do list |
765 | done | | 796 | done |
766 | .Ed | | 797 | .Ed |
767 | .Pp | | 798 | .Pp |
768 | The words are expanded, and then the list is executed repeatedly with the | | 799 | The words are expanded, or "$@" if no words are given, |
| | | 800 | and then the list is executed repeatedly with the |
769 | variable set to each word in turn. | | 801 | variable set to each word in turn. |
770 | do and done may be replaced with | | 802 | do and done may be replaced with |
771 | .Dq { | | 803 | .Dq { |
772 | and | | 804 | and |
773 | .Dq } . | | 805 | .Dq } , |
| | | 806 | but doing so is non-standard and not recommended. |
774 | .Pp | | 807 | .Pp |
775 | The syntax of the break and continue command is | | 808 | The syntax of the break and continue command is |
776 | .Bd -literal -offset indent | | 809 | .Bd -literal -offset indent |
777 | break [ num ] | | 810 | break [ num ] |
778 | continue [ num ] | | 811 | continue [ num ] |
779 | .Ed | | 812 | .Ed |
780 | .Pp | | 813 | .Pp |
781 | Break terminates the num innermost for or while loops. | | 814 | Break terminates the num innermost for or while loops. |
782 | Continue continues with the next iteration of the innermost loop. | | 815 | Continue continues with the next iteration of the innermost loop. |
783 | These are implemented as built-in commands. | | 816 | These are implemented as built-in commands. |
784 | .Pp | | 817 | .Pp |
785 | The syntax of the case command is | | 818 | The syntax of the case command is |
786 | .Bd -literal -offset indent | | 819 | .Bd -literal -offset indent |
| @@ -811,88 +844,178 @@ Grouping commands together this way allo | | | @@ -811,88 +844,178 @@ Grouping commands together this way allo |
811 | their output as though they were one program: | | 844 | their output as though they were one program: |
812 | .Bd -literal -offset indent | | 845 | .Bd -literal -offset indent |
813 | { echo -n \*q hello \*q ; echo \*q world" ; } \*[Gt] greeting | | 846 | { echo -n \*q hello \*q ; echo \*q world" ; } \*[Gt] greeting |
814 | .Ed | | 847 | .Ed |
815 | .Pp | | 848 | .Pp |
816 | Note that | | 849 | Note that |
817 | .Dq } | | 850 | .Dq } |
818 | must follow a control operator (here, | | 851 | must follow a control operator (here, |
819 | .Dq \&; ) | | 852 | .Dq \&; ) |
820 | so that it is recognized as a reserved word and not as another command argument. | | 853 | so that it is recognized as a reserved word and not as another command argument. |
821 | .Ss Functions | | 854 | .Ss Functions |
822 | The syntax of a function definition is | | 855 | The syntax of a function definition is |
823 | .Pp | | 856 | .Pp |
824 | .Dl name ( ) command | | 857 | .Dl name ( ) command [ redirect... ] |
825 | .Pp | | 858 | .Pp |
826 | A function definition is an executable statement; when executed it | | 859 | A function definition is an executable statement; when executed it |
827 | installs a function named name and returns an exit status of zero. | | 860 | installs a function named name and returns an exit status of zero. |
828 | The command is normally a list enclosed between | | 861 | The command is normally a list enclosed between |
829 | .Dq { | | 862 | .Dq { |
830 | and | | 863 | and |
831 | .Dq } . | | 864 | .Dq } . |
| | | 865 | The standard syntax also allows the command to be any of the other |
| | | 866 | compound commands, or a sub-shell, all of which are supported. |
| | | 867 | As an extension, this shell also allows a simple command to be |
| | | 868 | used, though users should be aware this is non-standard syntax. |
| | | 869 | This means that |
| | | 870 | .Dl l() ls "$@" |
| | | 871 | works to make |
| | | 872 | .Dq l |
| | | 873 | an alternative name for the |
| | | 874 | .Ic ls |
| | | 875 | command. |
| | | 876 | .Pp |
| | | 877 | If the optional redirect, (see |
| | | 878 | .Sx Redirections ) , |
| | | 879 | which may be of any of the normal forms, |
| | | 880 | is given, it is applied each time the |
| | | 881 | function is called. |
| | | 882 | This means that a simple |
| | | 883 | .Dq "Hello World |
| | | 884 | function might be written (in the extended syntax) as: |
| | | 885 | .Dl hello() cat <<EOF |
| | | 886 | .Dl Hello World! |
| | | 887 | .Dl EOF |
| | | 888 | To be correctly standards conforming this should be re-written as: |
| | | 889 | .Dl hello() { cat; } <<EOF |
| | | 890 | .Dl Hello World! |
| | | 891 | .Dl EOF |
| | | 892 | Note the distinction between those forms, and |
| | | 893 | .Dl hello() { cat <<EOF |
| | | 894 | .Dl Hello World! |
| | | 895 | .Dl EOF |
| | | 896 | .Dl \&} |
| | | 897 | which reads and processes the |
| | | 898 | .Ic "here document |
| | | 899 | each time the shell executes the function, and which applies |
| | | 900 | that input only to the cat command, not to any other commands |
| | | 901 | that might appear in the function. |
832 | .Pp | | 902 | .Pp |
833 | Variables may be declared to be local to a function by using a local | | 903 | Variables may be declared to be local to a function by using a local |
834 | command. | | 904 | command. |
835 | This should appear as the first statement of a function, and the syntax is | | 905 | This should appear as the first statement of a function, and the syntax is |
836 | .Pp | | 906 | .Pp |
837 | .Dl local [ variable | - ] ... | | 907 | .Dl local [ variable | - ] ... |
838 | .Pp | | 908 | .Pp |
839 | .Dq Local | | 909 | .Dq Ic local |
840 | is implemented as a built-in command. | | 910 | is implemented as a built-in command. |
841 | .Pp | | 911 | .Pp |
842 | When a variable is made local, it inherits the initial value and exported | | 912 | When a variable is made local, it inherits the initial value and exported, |
| | | 913 | unexportable, |
843 | and read-only flags from the variable with the same name in the surrounding | | 914 | and read-only flags from the variable with the same name in the surrounding |
844 | scope, if there is one. | | 915 | scope, if there is one. |
845 | Otherwise, the variable is initially unset. | | 916 | Otherwise, the variable is initially unset. |
| | | 917 | Making a read-only variable local is possible, but pointless. |
| | | 918 | If the |
| | | 919 | .Ic readonly |
| | | 920 | command is applied to a variable that has been declared local, |
| | | 921 | the variable cannot be (further) modified within the function, |
| | | 922 | or any other functions it calls, however when the function returns, |
| | | 923 | the previous status (and value) of the variable is returned. |
| | | 924 | .Pp |
| | | 925 | Values may be given to local variables on the |
| | | 926 | .Ic local |
| | | 927 | command line in a similar fashion as used for |
| | | 928 | .Ic export |
| | | 929 | and |
| | | 930 | .Ic readonly . |
| | | 931 | .Pp |
846 | The shell uses dynamic scoping, so that if you make the variable x local to | | 932 | The shell uses dynamic scoping, so that if you make the variable x local to |
847 | function f, which then calls function g, references to the variable x made | | 933 | function f, which then calls function g, references to the variable x made |
848 | inside g will refer to the variable x declared inside f, not to the global | | 934 | inside g will refer to the variable x declared inside f, not to the global |
849 | variable named x. | | 935 | variable named x. |
850 | .Pp | | 936 | .Pp |
| | | 937 | Note that the parameters $1, $2, ... (see |
| | | 938 | .Sx Positional Parameters ) , |
| | | 939 | and $#, $* and $@ (see |
| | | 940 | .Sx Special Parameters ) , |
| | | 941 | are always made local in all functions, and are reset inside the |
| | | 942 | function to represent the options and arguments passed to the function. |
| | | 943 | Note that $0 however retains the value it had outside the function, |
| | | 944 | as do all the other special parameters. |
| | | 945 | .Pp |
851 | The only special parameter that can be made local is | | 946 | The only special parameter that can be made local is |
852 | .Dq - . | | 947 | .Dq - . |
853 | Making | | 948 | Making |
854 | .Dq - | | 949 | .Dq - |
855 | local causes any shell options that are changed via the set command inside the | | 950 | local causes any shell options that are changed via the set command inside the |
856 | function to be restored to their original values when the function | | 951 | function to be restored to their original values when the function |
857 | returns. | | 952 | returns. |
858 | .Pp | | 953 | .Pp |
| | | 954 | It is a syntax error to use |
| | | 955 | .Ic local |
| | | 956 | outside the scope of a function definition. |
| | | 957 | When used inside a function, it exits with status 0. |
| | | 958 | .Pp |
859 | The syntax of the return command is | | 959 | The syntax of the return command is |
860 | .Pp | | 960 | .Pp |
861 | .Dl return [ exitstatus ] | | 961 | .Dl return [ exitstatus ] |
862 | .Pp | | 962 | .Pp |
863 | It terminates the currently executing function. | | 963 | It terminates the currently executing function or |
| | | 964 | .Dq \&. |
| | | 965 | script. |
864 | Return is implemented as a built-in command. | | 966 | Return is implemented as a built-in command. |
| | | 967 | The exit status of the function (or |
| | | 968 | .Dl \&. |
| | | 969 | command) is either that given on the |
| | | 970 | .Ic return |
| | | 971 | command line, or the value of the special parameter |
| | | 972 | .Dq $? |
| | | 973 | immediately before the return was executed. |
865 | .Ss Variables and Parameters | | 974 | .Ss Variables and Parameters |
866 | The shell maintains a set of parameters. | | 975 | The shell maintains a set of parameters. |
867 | A parameter denoted by a name is called a variable. | | 976 | A parameter denoted by a name is called a variable. |
868 | When starting up, the shell turns all the environment | | 977 | When starting up, the shell turns all the environment |
869 | variables into shell variables. | | 978 | variables into shell variables. |
870 | New variables can be set using the form | | 979 | New variables can be set using the form |
871 | .Pp | | 980 | .Pp |
872 | .Dl name=value | | 981 | .Dl name=value |
873 | .Pp | | 982 | .Pp |
874 | Variables set by the user must have a name consisting solely of | | 983 | Variables set by the user must have a name consisting solely of |
875 | alphabetics, numerics, and underscores - the first of which must not be | | 984 | alphabetics, numerics, and underscores - the first of which must not be |
876 | numeric. | | 985 | numeric. |
877 | A parameter can also be denoted by a number or a special | | 986 | A parameter can also be denoted by a number or a special |
878 | character as explained below. | | 987 | character as explained below. |
879 | .Ss Positional Parameters | | 988 | .Ss Positional Parameters |
880 | A positional parameter is a parameter denoted by a number (n \*[Gt] 0). | | 989 | A positional parameter is a parameter denoted by a number (n \*[Gt] 0). |
881 | The shell sets these initially to the values of its command line arguments | | 990 | The shell sets these initially to the values of its command line arguments |
882 | that follow the name of the shell script. | | 991 | that follow the name of the shell script. |
883 | The | | 992 | The |
884 | .Ic set | | 993 | .Ic set |
885 | built-in can also be used to set or reset them. | | 994 | built-in can also be used to set or reset them, and |
| | | 995 | .Ic shift |
| | | 996 | can be used to manipulate the list. |
| | | 997 | .Pp |
| | | 998 | To refer to the 10th (and later) positional parameters, |
| | | 999 | the form ${n} must be used. |
| | | 1000 | Without the braces, a digit following |
| | | 1001 | .Dq $ |
| | | 1002 | can only refer to one of the first 9 positional parameters, |
| | | 1003 | or the special parameter |
| | | 1004 | .Dq 0 . |
| | | 1005 | The word |
| | | 1006 | .Dq $10 |
| | | 1007 | is treated identically to |
| | | 1008 | .Dq ${1}0 . |
886 | .Ss Special Parameters | | 1009 | .Ss Special Parameters |
887 | A special parameter is a parameter denoted by one of the following special | | 1010 | A special parameter is a parameter denoted by one of the following special |
888 | characters. | | 1011 | characters. |
889 | The value of the parameter is listed next to its character. | | 1012 | The value of the parameter is listed next to its character. |
890 | .Bl -tag -width thinhyphena | | 1013 | .Bl -tag -width thinhyphena |
891 | .It * | | 1014 | .It * |
892 | Expands to the positional parameters, starting from one. | | 1015 | Expands to the positional parameters, starting from one. |
893 | When the | | 1016 | When the |
894 | expansion occurs within a double-quoted string it expands to a single | | 1017 | expansion occurs within a double-quoted string it expands to a single |
895 | field with the value of each parameter separated by the first character of | | 1018 | field with the value of each parameter separated by the first character of |
896 | the | | 1019 | the |
897 | .Ev IFS | | 1020 | .Ev IFS |
898 | variable, or by a | | 1021 | variable, or by a |
| @@ -926,26 +1049,32 @@ Expands to the number of positional para | | | @@ -926,26 +1049,32 @@ Expands to the number of positional para |
926 | Expands to the exit status of the most recent pipeline. | | 1049 | Expands to the exit status of the most recent pipeline. |
927 | .It - (Hyphen.) | | 1050 | .It - (Hyphen.) |
928 | Expands to the current option flags (the single-letter | | 1051 | Expands to the current option flags (the single-letter |
929 | option names concatenated into a string) as specified on | | 1052 | option names concatenated into a string) as specified on |
930 | invocation, by the set built-in command, or implicitly | | 1053 | invocation, by the set built-in command, or implicitly |
931 | by the shell. | | 1054 | by the shell. |
932 | .It $ | | 1055 | .It $ |
933 | Expands to the process ID of the invoked shell. | | 1056 | Expands to the process ID of the invoked shell. |
934 | A subshell retains the same value of $ as its parent. | | 1057 | A subshell retains the same value of $ as its parent. |
935 | .It \&! | | 1058 | .It \&! |
936 | Expands to the process ID of the most recent background | | 1059 | Expands to the process ID of the most recent background |
937 | command executed from the current shell. | | 1060 | command executed from the current shell. |
938 | For a pipeline, the process ID is that of the last command in the pipeline. | | 1061 | For a pipeline, the process ID is that of the last command in the pipeline. |
| | | 1062 | If no background commands have yet been started by the shell, then |
| | | 1063 | .Dq \&! |
| | | 1064 | will be unset. |
| | | 1065 | Once set, the value of |
| | | 1066 | .Dq \&! |
| | | 1067 | will be retained until another background command is started. |
939 | .It 0 (Zero.) | | 1068 | .It 0 (Zero.) |
940 | Expands to the name of the shell or shell script. | | 1069 | Expands to the name of the shell or shell script. |
941 | .El | | 1070 | .El |
942 | .Ss Word Expansions | | 1071 | .Ss Word Expansions |
943 | This section describes the various expansions that are performed on words. | | 1072 | This section describes the various expansions that are performed on words. |
944 | Not all expansions are performed on every word, as explained later. | | 1073 | Not all expansions are performed on every word, as explained later. |
945 | .Pp | | 1074 | .Pp |
946 | Tilde expansions, parameter expansions, command substitutions, arithmetic | | 1075 | Tilde expansions, parameter expansions, command substitutions, arithmetic |
947 | expansions, and quote removals that occur within a single word expand to a | | 1076 | expansions, and quote removals that occur within a single word expand to a |
948 | single field. | | 1077 | single field. |
949 | It is only field splitting or pathname expansion that can | | 1078 | It is only field splitting or pathname expansion that can |
950 | create multiple fields from a single word. | | 1079 | create multiple fields from a single word. |
951 | The single exception to this | | 1080 | The single exception to this |
| @@ -1013,27 +1142,27 @@ If a parameter expansion occurs inside d | | | @@ -1013,27 +1142,27 @@ If a parameter expansion occurs inside d |
1013 | Pathname expansion is not performed on the results of the expansion. | | 1142 | Pathname expansion is not performed on the results of the expansion. |
1014 | .It | | 1143 | .It |
1015 | Field splitting is not performed on the results of the | | 1144 | Field splitting is not performed on the results of the |
1016 | expansion, with the exception of the special rules for @. | | 1145 | expansion, with the exception of the special rules for @. |
1017 | .El | | 1146 | .El |
1018 | .Pp | | 1147 | .Pp |
1019 | In addition, a parameter expansion can be modified by using one of the | | 1148 | In addition, a parameter expansion can be modified by using one of the |
1020 | following formats. | | 1149 | following formats. |
1021 | If the | | 1150 | If the |
1022 | .Dq Dv \&: | | 1151 | .Dq Dv \&: |
1023 | is omitted in the following modifiers, then the expansion is applied only | | 1152 | is omitted in the following modifiers, then the expansion is applied only |
1024 | to unset parameters, not null ones. | | 1153 | to unset parameters, not null ones. |
1025 | .Bl -tag -width aaparameterwordaaaaa | | 1154 | .Bl -tag -width aaparameterwordaaaaa |
1026 | .It ${parameter:-word} | | 1155 | .It ${parameter:\(miword} |
1027 | Use Default Values. | | 1156 | Use Default Values. |
1028 | If parameter is unset or null, the expansion of word | | 1157 | If parameter is unset or null, the expansion of word |
1029 | is substituted; otherwise, the value of parameter is substituted. | | 1158 | is substituted; otherwise, the value of parameter is substituted. |
1030 | .It ${parameter:=word} | | 1159 | .It ${parameter:=word} |
1031 | Assign Default Values. | | 1160 | Assign Default Values. |
1032 | If parameter is unset or null, the expansion of | | 1161 | If parameter is unset or null, the expansion of |
1033 | word is assigned to parameter. | | 1162 | word is assigned to parameter. |
1034 | In all cases, the final value of parameter is substituted. | | 1163 | In all cases, the final value of parameter is substituted. |
1035 | Only variables, not positional parameters or special | | 1164 | Only variables, not positional parameters or special |
1036 | parameters, can be assigned in this way. | | 1165 | parameters, can be assigned in this way. |
1037 | .It ${parameter:?[word]} | | 1166 | .It ${parameter:?[word]} |
1038 | Indicate Error if Null or Unset. | | 1167 | Indicate Error if Null or Unset. |
1039 | If parameter is unset or null, the | | 1168 | If parameter is unset or null, the |
| @@ -1130,44 +1259,72 @@ of the C language, and are evaluated usi | | | @@ -1130,44 +1259,72 @@ of the C language, and are evaluated usi |
1130 | .Ql intmax_t | | 1259 | .Ql intmax_t |
1131 | data type (this is an extension to | | 1260 | data type (this is an extension to |
1132 | .Tn POSIX , | | 1261 | .Tn POSIX , |
1133 | which requires only | | 1262 | which requires only |
1134 | .Ql long | | 1263 | .Ql long |
1135 | arithmetic). | | 1264 | arithmetic). |
1136 | Shell variables may be referenced by name inside an arithmetic | | 1265 | Shell variables may be referenced by name inside an arithmetic |
1137 | expression, without needing a | | 1266 | expression, without needing a |
1138 | .Dq \&$ | | 1267 | .Dq \&$ |
1139 | sign. | | 1268 | sign. |
1140 | .Ss White Space Splitting (Field Splitting) | | 1269 | .Ss White Space Splitting (Field Splitting) |
1141 | After parameter expansion, command substitution, and | | 1270 | After parameter expansion, command substitution, and |
1142 | arithmetic expansion the shell scans the results of | | 1271 | arithmetic expansion the shell scans the results of |
1143 | expansions and substitutions that did not occur in double quotes for | | 1272 | expansions and substitutions that did not occur in double quotes, |
1144 | field splitting and multiple fields can result. | | 1273 | and |
| | | 1274 | .Dq $@ |
| | | 1275 | even if it did, |
| | | 1276 | for field splitting and multiple fields can result. |
1145 | .Pp | | 1277 | .Pp |
1146 | The shell treats each character of the | | 1278 | The shell treats each character of the |
1147 | .Ev IFS | | 1279 | .Ev IFS |
1148 | as a delimiter and use the delimiters to split the results of parameter | | 1280 | as a delimiter and uses the delimiters to split the results of parameter |
1149 | expansion and command substitution into fields. | | 1281 | expansion and command substitution into fields. |
1150 | .Pp | | 1282 | .Pp |
1151 | Non-whitespace characters in | | 1283 | Non-whitespace characters in |
1152 | .Ev IFS | | 1284 | .Ev IFS |
1153 | are treated strictly as parameter terminators. | | 1285 | are treated strictly as parameter separators. |
1154 | So adjacent non-whitespace | | 1286 | So adjacent non-whitespace |
1155 | .Ev IFS | | 1287 | .Ev IFS |
1156 | characters will produce empty parameters. | | 1288 | characters will produce empty parameters. |
| | | 1289 | On the other hand, any sequence of whitespace |
| | | 1290 | characters that occur in |
| | | 1291 | .Ev IFS |
| | | 1292 | (known as |
| | | 1293 | .Ev IFS |
| | | 1294 | whitespace) |
| | | 1295 | can occur, leading and trailing |
| | | 1296 | .Ev IFS |
| | | 1297 | whitespace, and |
| | | 1298 | .Ev IFS |
| | | 1299 | whitespace surrounding a non whitespace |
| | | 1300 | .Ev IFS |
| | | 1301 | delimiter, is removed. |
| | | 1302 | Any sequence of |
| | | 1303 | .Ev IFS |
| | | 1304 | whitespace characters without a non-whitespace |
| | | 1305 | .Ev IFS |
| | | 1306 | delimiter acts as a field separator. |
1157 | .Pp | | 1307 | .Pp |
1158 | If | | 1308 | If |
1159 | .Ev IFS | | 1309 | .Ev IFS |
1160 | is unset it is assumed to contain space, tab, and newline. | | 1310 | is unset it is assumed to contain space, tab, and newline, |
| | | 1311 | all of which are |
| | | 1312 | .Ev IFS |
| | | 1313 | whitespace characters. |
| | | 1314 | If |
| | | 1315 | .Ev IFS |
| | | 1316 | is set to a null string, there are no delimiters, |
| | | 1317 | and no field splitting occurs. |
1161 | .Ss Pathname Expansion (File Name Generation) | | 1318 | .Ss Pathname Expansion (File Name Generation) |
1162 | Unless the | | 1319 | Unless the |
1163 | .Fl f | | 1320 | .Fl f |
1164 | flag is set, file name generation is performed after word splitting is | | 1321 | flag is set, file name generation is performed after word splitting is |
1165 | complete. | | 1322 | complete. |
1166 | Each word is viewed as a series of patterns, separated by slashes. | | 1323 | Each word is viewed as a series of patterns, separated by slashes. |
1167 | The process of expansion replaces the word with the names of all | | 1324 | The process of expansion replaces the word with the names of all |
1168 | existing files whose names can be formed by replacing each pattern with a | | 1325 | existing files whose names can be formed by replacing each pattern with a |
1169 | string that matches the specified pattern. | | 1326 | string that matches the specified pattern. |
1170 | There are two restrictions on | | 1327 | There are two restrictions on |
1171 | this: first, a pattern cannot match a string containing a slash, and | | 1328 | this: first, a pattern cannot match a string containing a slash, and |
1172 | second, a pattern cannot match a string starting with a period unless the | | 1329 | second, a pattern cannot match a string starting with a period unless the |
1173 | first character of the pattern is a period. | | 1330 | first character of the pattern is a period. |
| @@ -1210,94 +1367,95 @@ matches a | | | @@ -1210,94 +1367,95 @@ matches a |
1210 | .Dq \&[ | | 1367 | .Dq \&[ |
1211 | rather than introducing a character class. | | 1368 | rather than introducing a character class. |
1212 | A character class matches any of the characters between the square brackets. | | 1369 | A character class matches any of the characters between the square brackets. |
1213 | A named class of characters (see | | 1370 | A named class of characters (see |
1214 | .Xr wctype 3 ) | | 1371 | .Xr wctype 3 ) |
1215 | may be specified by surrounding the name with | | 1372 | may be specified by surrounding the name with |
1216 | .Pq Dq [: | | 1373 | .Pq Dq [: |
1217 | and | | 1374 | and |
1218 | .Pq Dq :] . | | 1375 | .Pq Dq :] . |
1219 | For example, | | 1376 | For example, |
1220 | .Pq Dq [[:alpha:]] | | 1377 | .Pq Dq [[:alpha:]] |
1221 | is a shell pattern that matches a single letter. | | 1378 | is a shell pattern that matches a single letter. |
1222 | A range of characters may be specified using a minus sign | | 1379 | A range of characters may be specified using a minus sign |
1223 | .Pq Dq - . | | 1380 | .Pq Dq \(mi . |
1224 | The character class may be complemented | | 1381 | The character class may be complemented |
1225 | by making an exclamation mark | | 1382 | by making an exclamation mark |
1226 | .Pq Dq \&! | | 1383 | .Pq Dq \&! |
1227 | the first character of the character class. | | 1384 | the first character of the character class. |
1228 | .Pp | | 1385 | .Pp |
1229 | To include a | | 1386 | To include a |
1230 | .Dq \&] | | 1387 | .Dq \&] |
1231 | in a character class, make it the first character listed (after the | | 1388 | in a character class, make it the first character listed (after the |
1232 | .Dq \&! , | | 1389 | .Dq \&! , |
1233 | if any). | | 1390 | if any). |
1234 | To include a | | 1391 | To include a |
1235 | .Dq - , | | 1392 | .Dq \(mi , |
1236 | make it the first or last character listed. | | 1393 | make it the first or last character listed. |
1237 | .Ss Built-ins | | 1394 | .Ss Built-ins |
1238 | This section lists the built-in commands which are built-in because they | | 1395 | This section lists the built-in commands which are built-in because they |
1239 | need to perform some operation that can't be performed by a separate | | 1396 | need to perform some operation that can't be performed by a separate |
1240 | process. | | 1397 | process. |
1241 | In addition to these, there are several other commands that may | | 1398 | In addition to these, there are several other commands that may |
1242 | be built in for efficiency (e.g. | | 1399 | be built in for efficiency (e.g. |
1243 | .Xr printf 1 , | | 1400 | .Xr printf 1 , |
1244 | .Xr echo 1 , | | 1401 | .Xr echo 1 , |
1245 | .Xr test 1 , | | 1402 | .Xr test 1 , |
1246 | etc). | | 1403 | etc). |
1247 | .Bl -tag -width 5n | | 1404 | .Bl -tag -width 5n |
1248 | .It : [ Ar arg ... ] | | 1405 | .It : [ Ar arg ... ] |
1249 | A null command that returns a 0 (true) exit value. | | 1406 | A null command that returns a 0 (true) exit value. |
1250 | Any arguments are ignored. | | 1407 | Any arguments or redirects are evaluated, then ignored. |
1251 | .It \&. file | | 1408 | .It \&. file |
1252 | The dot command reads and executes the commands from the specified | | 1409 | The dot command reads and executes the commands from the specified |
1253 | .Ar file | | 1410 | .Ar file |
1254 | in the current shell environment. | | 1411 | in the current shell environment. |
1255 | The file does not need to be executable and is looked up from the directories | | 1412 | The file does not need to be executable and is looked up from the directories |
1256 | listed in the | | 1413 | listed in the |
1257 | .Ev PATH | | 1414 | .Ev PATH |
1258 | variable if it does not contain a directory separator | | 1415 | variable if its name does not contain a directory separator |
1259 | .Pq Sq / . | | 1416 | .Pq Sq / . |
1260 | The return command can be used for a premature return from the sourced file. | | 1417 | The return command can be used for a premature return from the sourced file. |
1261 | .Pp | | 1418 | .Pp |
1262 | The POSIX standard is unclear on how loop control keywords (break | | 1419 | The POSIX standard has been unclear on how loop control keywords (break |
1263 | and continue) behave across a dot command boundary. | | 1420 | and continue) behave across a dot command boundary. |
1264 | This implementation allows them to control loops surrounding the dot command, | | 1421 | This implementation allows them to control loops surrounding the dot command, |
1265 | but obviously such behavior should not be relied on. | | 1422 | but obviously such behavior should not be relied on. |
| | | 1423 | It is now permitted by the standard, but not required. |
1266 | .It alias Op Ar name Ns Op Ar "=string ..." | | 1424 | .It alias Op Ar name Ns Op Ar "=string ..." |
1267 | If | | 1425 | If |
1268 | .Ar name=string | | 1426 | .Ar name=string |
1269 | is specified, the shell defines the alias | | 1427 | is specified, the shell defines the alias |
1270 | .Ar name | | 1428 | .Ar name |
1271 | with value | | 1429 | with value |
1272 | .Ar string . | | 1430 | .Ar string . |
1273 | If just | | 1431 | If just |
1274 | .Ar name | | 1432 | .Ar name |
1275 | is specified, the value of the alias | | 1433 | is specified, the value of the alias |
1276 | .Ar name | | 1434 | .Ar name |
1277 | is printed. | | 1435 | is printed. |
1278 | With no arguments, the | | 1436 | With no arguments, the |
1279 | .Ic alias | | 1437 | .Ic alias |
1280 | built-in prints the | | 1438 | built-in prints the |
1281 | names and values of all defined aliases (see | | 1439 | names and values of all defined aliases (see |
1282 | .Ic unalias ) . | | 1440 | .Ic unalias ) . |
1283 | .It bg [ Ar job ] ... | | 1441 | .It bg [ Ar job ] ... |
1284 | Continue the specified jobs (or the current job if no | | 1442 | Continue the specified jobs (or the current job if no |
1285 | jobs are given) in the background. | | 1443 | jobs are given) in the background. |
1286 | .It command Oo Fl p Oc Oo Fl v Oc Oo Fl V Oc Ar command Oo Ar arg ... Oc | | 1444 | .It command Oo Fl p Oc Oo Fl v Oc Oo Fl V Oc Ar command Oo Ar arg ... Oc |
1287 | Execute the specified command but ignore shell functions when searching | | 1445 | Execute the specified command but ignore shell functions when searching |
1288 | for it. | | 1446 | for it. |
1289 | (This is useful when you | | 1447 | (This is useful when you |
1290 | have a shell function with the same name as a built-in command.) | | 1448 | have a shell function with the same name as a command.) |
1291 | .Bl -tag -width 5n | | 1449 | .Bl -tag -width 5n |
1292 | .It Fl p | | 1450 | .It Fl p |
1293 | search for command using a | | 1451 | search for command using a |
1294 | .Ev PATH | | 1452 | .Ev PATH |
1295 | that guarantees to find all the standard utilities. | | 1453 | that guarantees to find all the standard utilities. |
1296 | .It Fl V | | 1454 | .It Fl V |
1297 | Do not execute the command but | | 1455 | Do not execute the command but |
1298 | search for the command and print the resolution of the | | 1456 | search for the command and print the resolution of the |
1299 | command search. | | 1457 | command search. |
1300 | This is the same as the | | 1458 | This is the same as the |
1301 | .Ic type | | 1459 | .Ic type |
1302 | built-in. | | 1460 | built-in. |
1303 | .It Fl v | | 1461 | .It Fl v |
| @@ -1387,40 +1545,76 @@ or | | | @@ -1387,40 +1545,76 @@ or |
1387 | .Dv FD_CLOEXEC ) , | | 1545 | .Dv FD_CLOEXEC ) , |
1388 | unless the descriptors they point to refer to the standard input, | | 1546 | unless the descriptors they point to refer to the standard input, |
1389 | output, or error (file descriptors 0, 1, 2). | | 1547 | output, or error (file descriptors 0, 1, 2). |
1390 | Traditionally Bourne-like shells | | 1548 | Traditionally Bourne-like shells |
1391 | (except | | 1549 | (except |
1392 | .Xr ksh 1 ) , | | 1550 | .Xr ksh 1 ) , |
1393 | made those file descriptors available to exec'ed processes. | | 1551 | made those file descriptors available to exec'ed processes. |
1394 | .It exit Op Ar exitstatus | | 1552 | .It exit Op Ar exitstatus |
1395 | Terminate the shell process. | | 1553 | Terminate the shell process. |
1396 | If | | 1554 | If |
1397 | .Ar exitstatus | | 1555 | .Ar exitstatus |
1398 | is given it is used as the exit status of the shell; otherwise the | | 1556 | is given it is used as the exit status of the shell; otherwise the |
1399 | exit status of the preceding command is used. | | 1557 | exit status of the preceding command is used. |
1400 | .It export Ar name ... | | 1558 | .It export Oo Fl npx Oc Ar name ... |
1401 | .It export Fl p | | 1559 | .It export Fl p Oo Fl x Oc |
1402 | The specified names are exported so that they will appear in the | | 1560 | With no options, |
| | | 1561 | the specified names are exported so that they will appear in the |
1403 | environment of subsequent commands. | | 1562 | environment of subsequent commands. |
1404 | The only way to un-export a variable is to unset it. | | 1563 | With |
| | | 1564 | .Fl n |
| | | 1565 | the specified names are un-exported. |
| | | 1566 | Variables can also be un-exported using the unset builtin command. |
| | | 1567 | With |
| | | 1568 | .Fl x |
| | | 1569 | (exclude) the specified names are marked not to be exported, |
| | | 1570 | and any that had been exported, will be un-exported. |
| | | 1571 | Later attempts to export the variable will be refused. |
| | | 1572 | Note this does not prevent explicitly exporting a variable |
| | | 1573 | to a single command, script or function by preceding that |
| | | 1574 | command invocation by a variable assignment to that variable, |
| | | 1575 | provided the variable is not also readonly. |
| | | 1576 | That is |
| | | 1577 | .Dl export -x FOO ; # FOO will now not be exported by default |
| | | 1578 | .Dl FOO=some_value my_command |
| | | 1579 | still passes the value (FOO=some_value) to |
| | | 1580 | .Ic my_command |
| | | 1581 | through the environment. |
| | | 1582 | .Pp |
1405 | The shell allows the value of a variable to be set at the | | 1583 | The shell allows the value of a variable to be set at the |
1406 | same time it is exported by writing | | 1584 | same time it is exported by writing |
1407 | .Pp | | 1585 | .Pp |
1408 | .Dl export name=value | | 1586 | .Dl export name=value |
1409 | .Pp | | 1587 | .Pp |
1410 | With no arguments the export command lists the names of all exported variables. | | 1588 | With no arguments the export command lists the names of all exported variables, |
| | | 1589 | or if |
| | | 1590 | .Fl x |
| | | 1591 | was given, all variables marked not for export. |
1411 | With the | | 1592 | With the |
1412 | .Fl p | | 1593 | .Fl p |
1413 | option specified the output will be formatted suitably for non-interactive use. | | 1594 | option specified the output will be formatted suitably for non-interactive use. |
| | | 1595 | .Pp |
| | | 1596 | The |
| | | 1597 | .Ic export |
| | | 1598 | built-in exits with status 0, |
| | | 1599 | unless an invalid option, or option combination, is given, |
| | | 1600 | or unless an attempt is made to export a variable which has |
| | | 1601 | been marked as unavailable for export, |
| | | 1602 | in which cases it exits with status 1. |
| | | 1603 | .Pp |
| | | 1604 | Note that there is no restriction upon exporting, |
| | | 1605 | or un-exporting, readonly variables. |
| | | 1606 | The no-export flag can be reset by unsetting the variable |
| | | 1607 | and creating it again \(en provided it is not also readonly. |
1414 | .It fc Oo Fl e Ar editor Oc Oo Ar first Oo Ar last Oc Oc | | 1608 | .It fc Oo Fl e Ar editor Oc Oo Ar first Oo Ar last Oc Oc |
1415 | .It fc Fl l Oo Fl nr Oc Oo Ar first Oo Ar last Oc Oc | | 1609 | .It fc Fl l Oo Fl nr Oc Oo Ar first Oo Ar last Oc Oc |
1416 | .It fc Fl s Oo Ar old=new Oc Oo Ar first Oc | | 1610 | .It fc Fl s Oo Ar old=new Oc Oo Ar first Oc |
1417 | The | | 1611 | The |
1418 | .Ic fc | | 1612 | .Ic fc |
1419 | built-in lists, or edits and re-executes, commands previously entered | | 1613 | built-in lists, or edits and re-executes, commands previously entered |
1420 | to an interactive shell. | | 1614 | to an interactive shell. |
1421 | .Bl -tag -width 5n | | 1615 | .Bl -tag -width 5n |
1422 | .It Fl e No editor | | 1616 | .It Fl e No editor |
1423 | Use the editor named by editor to edit the commands. | | 1617 | Use the editor named by editor to edit the commands. |
1424 | The editor string is a command name, subject to search via the | | 1618 | The editor string is a command name, subject to search via the |
1425 | .Ev PATH | | 1619 | .Ev PATH |
1426 | variable. | | 1620 | variable. |
| @@ -1750,43 +1944,45 @@ If no arguments are present, the set com | | | @@ -1750,43 +1944,45 @@ If no arguments are present, the set com |
1750 | will clear all the positional parameters (equivalent to executing | | 1944 | will clear all the positional parameters (equivalent to executing |
1751 | .Dq shift $# . ) | | 1945 | .Dq shift $# . ) |
1752 | .It setvar Ar variable Ar value | | 1946 | .It setvar Ar variable Ar value |
1753 | Assigns value to variable. | | 1947 | Assigns value to variable. |
1754 | (In general it is better to write | | 1948 | (In general it is better to write |
1755 | variable=value rather than using | | 1949 | variable=value rather than using |
1756 | .Ic setvar . | | 1950 | .Ic setvar . |
1757 | .Ic setvar | | 1951 | .Ic setvar |
1758 | is intended to be used in | | 1952 | is intended to be used in |
1759 | functions that assign values to variables whose names are passed as | | 1953 | functions that assign values to variables whose names are passed as |
1760 | parameters.) | | 1954 | parameters.) |
1761 | .It shift Op Ar n | | 1955 | .It shift Op Ar n |
1762 | Shift the positional parameters n times. | | 1956 | Shift the positional parameters n times. |
1763 | A | | 1957 | If n is omitted, 1 is assumed. |
| | | 1958 | Each |
1764 | .Ic shift | | 1959 | .Ic shift |
1765 | sets the value of | | 1960 | sets the value of |
1766 | .Va $1 | | 1961 | .Va $1 |
1767 | to the value of | | 1962 | to the previous value of |
1768 | .Va $2 , | | 1963 | .Va $2 , |
1769 | the value of | | 1964 | the value of |
1770 | .Va $2 | | 1965 | .Va $2 |
1771 | to the value of | | 1966 | to the previous value of |
1772 | .Va $3 , | | 1967 | .Va $3 , |
1773 | and so on, decreasing | | 1968 | and so on, decreasing |
1774 | the value of | | 1969 | the value of |
1775 | .Va $# | | 1970 | .Va $# |
1776 | by one. | | 1971 | by one. |
1777 | If there are zero positional parameters, | | 1972 | The shift count must be less than or equal to the number of |
1778 | .Ic shift | | 1973 | positional parameters ( |
1779 | does nothing. | | 1974 | .Dq $# ) |
| | | 1975 | before the shift. |
1780 | .It trap Oo Fl l Oc | | 1976 | .It trap Oo Fl l Oc |
1781 | .It trap Oo Ar action Oc Ar signal ... | | 1977 | .It trap Oo Ar action Oc Ar signal ... |
1782 | Cause the shell to parse and execute action when any of the specified | | 1978 | Cause the shell to parse and execute action when any of the specified |
1783 | signals are received. | | 1979 | signals are received. |
1784 | The signals are specified by signal number or as the name of the signal. | | 1980 | The signals are specified by signal number or as the name of the signal. |
1785 | If | | 1981 | If |
1786 | .Ar signal | | 1982 | .Ar signal |
1787 | is | | 1983 | is |
1788 | .Li 0 | | 1984 | .Li 0 |
1789 | or its equivalent, EXIT, | | 1985 | or its equivalent, EXIT, |
1790 | the action is executed when the shell exits. | | 1986 | the action is executed when the shell exits. |
1791 | .Ar action | | 1987 | .Ar action |
1792 | may be null, which cause the specified signals to be ignored. | | 1988 | may be null, which cause the specified signals to be ignored. |
| @@ -1820,27 +2016,29 @@ Examples: | | | @@ -1820,27 +2016,29 @@ Examples: |
1820 | .Pp | | 2016 | .Pp |
1821 | List trapped signals and their corresponding action | | 2017 | List trapped signals and their corresponding action |
1822 | .Pp | | 2018 | .Pp |
1823 | .Dl trap -l | | 2019 | .Dl trap -l |
1824 | .Pp | | 2020 | .Pp |
1825 | Print a list of valid signals | | 2021 | Print a list of valid signals |
1826 | .Pp | | 2022 | .Pp |
1827 | .Dl trap '' INT QUIT tstp 30 | | 2023 | .Dl trap '' INT QUIT tstp 30 |
1828 | .Pp | | 2024 | .Pp |
1829 | Ignore signals INT QUIT TSTP USR1 | | 2025 | Ignore signals INT QUIT TSTP USR1 |
1830 | .Pp | | 2026 | .Pp |
1831 | .Dl trap date INT | | 2027 | .Dl trap date INT |
1832 | .Pp | | 2028 | .Pp |
1833 | Print date upon receiving signal INT | | 2029 | Run the |
| | | 2030 | .Dq date |
| | | 2031 | command (print the date) upon receiving signal INT |
1834 | .It type Op Ar name ... | | 2032 | .It type Op Ar name ... |
1835 | Interpret each name as a command and print the resolution of the command | | 2033 | Interpret each name as a command and print the resolution of the command |
1836 | search. | | 2034 | search. |
1837 | Possible resolutions are: | | 2035 | Possible resolutions are: |
1838 | shell keyword, alias, shell built-in, | | 2036 | shell keyword, alias, shell built-in, |
1839 | command, tracked alias and not found. | | 2037 | command, tracked alias and not found. |
1840 | For aliases the alias expansion is | | 2038 | For aliases the alias expansion is |
1841 | printed; for commands and tracked aliases the complete pathname of the | | 2039 | printed; for commands and tracked aliases the complete pathname of the |
1842 | command is printed. | | 2040 | command is printed. |
1843 | .It ulimit Oo Fl H \*(Ba Fl S Oc Oo Fl a \*(Ba Fl btfdscmlrpnv Oo Ar value Oc Oc | | 2041 | .It ulimit Oo Fl H \*(Ba Fl S Oc Oo Fl a \*(Ba Fl btfdscmlrpnv Oo Ar value Oc Oc |
1844 | Inquire about or set the hard or soft limits on processes or set new | | 2042 | Inquire about or set the hard or soft limits on processes or set new |
1845 | limits. | | 2043 | limits. |
1846 | The choice between hard limit (which no process is allowed to | | 2044 | The choice between hard limit (which no process is allowed to |
| @@ -1909,35 +2107,74 @@ utility. | | | @@ -1909,35 +2107,74 @@ utility. |
1909 | .Pp | | 2107 | .Pp |
1910 | .It umask Op Ar mask | | 2108 | .It umask Op Ar mask |
1911 | Set the value of umask (see | | 2109 | Set the value of umask (see |
1912 | .Xr umask 2 ) | | 2110 | .Xr umask 2 ) |
1913 | to the specified octal value. | | 2111 | to the specified octal value. |
1914 | If the argument is omitted, the umask value is printed. | | 2112 | If the argument is omitted, the umask value is printed. |
1915 | .It unalias Oo Fl a Oc Oo Ar name Oc | | 2113 | .It unalias Oo Fl a Oc Oo Ar name Oc |
1916 | If | | 2114 | If |
1917 | .Ar name | | 2115 | .Ar name |
1918 | is specified, the shell removes that alias. | | 2116 | is specified, the shell removes that alias. |
1919 | If | | 2117 | If |
1920 | .Fl a | | 2118 | .Fl a |
1921 | is specified, all aliases are removed. | | 2119 | is specified, all aliases are removed. |
1922 | .It unset Ar name ... | | 2120 | .It unset Oo Fl efv Oc Ar name ... |
1923 | The specified variables and functions are unset and unexported. | | 2121 | If |
1924 | If a given name corresponds to both a variable and a function, both | | 2122 | .Fl v |
1925 | the variable and the function are unset. | | 2123 | is specified, the specified variables are unset and unexported. |
| | | 2124 | Readonly variables cannot be unset. |
| | | 2125 | If |
| | | 2126 | .Fl f |
| | | 2127 | is specified, the specified functions are undefined. |
| | | 2128 | If |
| | | 2129 | .Fl e |
| | | 2130 | is given, the specified variables are unexported, but otherwise unchanged. |
| | | 2131 | .Pp |
| | | 2132 | If no flags are provided |
| | | 2133 | .Fl v |
| | | 2134 | is assumed. |
| | | 2135 | If |
| | | 2136 | .Fl f |
| | | 2137 | is given with one (or both) of |
| | | 2138 | .Fl v |
| | | 2139 | or |
| | | 2140 | .Fl e , |
| | | 2141 | then the named variables will be unset, or unexported, and functions |
| | | 2142 | of the same names will be undefined. |
| | | 2143 | It makes no sense to give both |
| | | 2144 | .Fl v |
| | | 2145 | and |
| | | 2146 | .Fl e |
| | | 2147 | as unsetting a variable unexports it as well. |
| | | 2148 | However doing so is not an error, the last specified is used. |
| | | 2149 | The exit status is 0, unless an attempt was made to unset |
| | | 2150 | a readonly variable, in which case the exit status is 1. |
| | | 2151 | It is not an error to unset (or undefine) a variable (or function) |
| | | 2152 | that is not currently set (or defined.) |
1926 | .It wait Op Ar job | | 2153 | .It wait Op Ar job |
1927 | Wait for the specified job to complete and return the exit status of the | | 2154 | Wait for the specified job to complete and return the exit status of the |
1928 | last process in the job. | | 2155 | last process in the job, or 127 if the job is not a current child of |
| | | 2156 | the shell. |
1929 | If the argument is omitted, wait for all jobs to | | 2157 | If the argument is omitted, wait for all jobs to |
1930 | complete and then return an exit status of zero. | | 2158 | complete and then return an exit status of zero. |
| | | 2159 | If the wait is interrupted by a signal, |
| | | 2160 | its exit status will be greater than 128. |
| | | 2161 | .Pp |
| | | 2162 | Once waited upon, by specific process number or job-id, |
| | | 2163 | or by a |
| | | 2164 | .Ic wait |
| | | 2165 | with no argumentss, |
| | | 2166 | knowledge of the child is removed from the system, |
| | | 2167 | and it cannot be waited upon again. |
1931 | .El | | 2168 | .El |
1932 | .Ss Command Line Editing | | 2169 | .Ss Command Line Editing |
1933 | When | | 2170 | When |
1934 | .Nm | | 2171 | .Nm |
1935 | is being used interactively from a terminal, the current command | | 2172 | is being used interactively from a terminal, the current command |
1936 | and the command history (see | | 2173 | and the command history (see |
1937 | .Ic fc | | 2174 | .Ic fc |
1938 | in the | | 2175 | in the |
1939 | .Sx Built-ins | | 2176 | .Sx Built-ins |
1940 | section) | | 2177 | section) |
1941 | can be edited using emacs-mode or vi-mode command-line editing. | | 2178 | can be edited using emacs-mode or vi-mode command-line editing. |
1942 | The command | | 2179 | The command |
1943 | .Ql set -o emacs | | 2180 | .Ql set -o emacs |
| @@ -1974,98 +2211,110 @@ The | | | @@ -1974,98 +2211,110 @@ The |
1974 | mode uses commands similar to a subset available in | | 2211 | mode uses commands similar to a subset available in |
1975 | the | | 2212 | the |
1976 | .Xr emacs 1 | | 2213 | .Xr emacs 1 |
1977 | editor. | | 2214 | editor. |
1978 | With emacs-mode enabled, special keys can be used to modify the text | | 2215 | With emacs-mode enabled, special keys can be used to modify the text |
1979 | in the buffer using the control key. | | 2216 | in the buffer using the control key. |
1980 | .Pp | | 2217 | .Pp |
1981 | .Nm | | 2218 | .Nm |
1982 | uses the | | 2219 | uses the |
1983 | .Xr editline 3 | | 2220 | .Xr editline 3 |
1984 | library. | | 2221 | library. |
1985 | .Sh ENVIRONMENT | | 2222 | .Sh ENVIRONMENT |
1986 | .Bl -tag -width MAILCHECK | | 2223 | .Bl -tag -width MAILCHECK |
| | | 2224 | .It Ev CDPATH |
| | | 2225 | The search path used with the |
| | | 2226 | .Ic cd |
| | | 2227 | built-in. |
| | | 2228 | .It Ev HISTSIZE |
| | | 2229 | The number of lines in the history buffer for the shell. |
1987 | .It Ev HOME | | 2230 | .It Ev HOME |
1988 | Set automatically by | | 2231 | Set automatically by |
1989 | .Xr login 1 | | 2232 | .Xr login 1 |
1990 | from the user's login directory in the password file | | 2233 | from the user's login directory in the password file |
1991 | .Pq Xr passwd 5 . | | 2234 | .Pq Xr passwd 5 . |
1992 | This environment variable also functions as the default argument for the | | 2235 | This environment variable also functions as the default argument for the |
1993 | .Ic cd | | 2236 | .Ic cd |
1994 | built-in. | | 2237 | built-in. |
1995 | .It Ev PATH | | 2238 | .It Ev IFS |
1996 | The default search path for executables. | | 2239 | Input Field Separators. |
| | | 2240 | This is normally set to |
| | | 2241 | .Aq space , |
| | | 2242 | .Aq tab , |
| | | 2243 | and |
| | | 2244 | .Aq newline . |
1997 | See the | | 2245 | See the |
1998 | .Sx Path Search | | 2246 | .Sx White Space Splitting |
1999 | section above. | | 2247 | section for more details. |
2000 | .It Ev CDPATH | | | |
2001 | The search path used with the | | | |
2002 | .Ic cd | | | |
2003 | built-in. | | | |
2004 | .It Ev LINENO | | | |
2005 | The current line number in the script or function. | | | |
2006 | .It Ev LANG | | 2248 | .It Ev LANG |
2007 | The string used to specify localization information that allows users | | 2249 | The string used to specify localization information that allows users |
2008 | to work with different culture-specific and language conventions. | | 2250 | to work with different culture-specific and language conventions. |
2009 | See | | 2251 | See |
2010 | .Xr nls 7 . | | 2252 | .Xr nls 7 . |
| | | 2253 | .It Ev LINENO |
| | | 2254 | The current line number in the script or function. |
2011 | .It Ev MAIL | | 2255 | .It Ev MAIL |
2012 | The name of a mail file, that will be checked for the arrival of new mail. | | 2256 | The name of a mail file, that will be checked for the arrival of new mail. |
2013 | Overridden by | | 2257 | Overridden by |
2014 | .Ev MAILPATH . | | 2258 | .Ev MAILPATH . |
2015 | .It Ev MAILCHECK | | 2259 | .It Ev MAILCHECK |
2016 | The frequency in seconds that the shell checks for the arrival of mail | | 2260 | The frequency in seconds that the shell checks for the arrival of mail |
2017 | in the files specified by the | | 2261 | in the files specified by the |
2018 | .Ev MAILPATH | | 2262 | .Ev MAILPATH |
2019 | or the | | 2263 | or the |
2020 | .Ev MAIL | | 2264 | .Ev MAIL |
2021 | file. | | 2265 | file. |
2022 | If set to 0, the check will occur at each prompt. | | 2266 | If set to 0, the check will occur at each prompt. |
2023 | .It Ev MAILPATH | | 2267 | .It Ev MAILPATH |
2024 | A colon | | 2268 | A colon |
2025 | .Dq \&: | | 2269 | .Dq \&: |
2026 | separated list of file names, for the shell to check for incoming mail. | | 2270 | separated list of file names, for the shell to check for incoming mail. |
2027 | This environment setting overrides the | | 2271 | This environment setting overrides the |
2028 | .Ev MAIL | | 2272 | .Ev MAIL |
2029 | setting. | | 2273 | setting. |
2030 | There is a maximum of 10 mailboxes that can be monitored at once. | | 2274 | There is a maximum of 10 mailboxes that can be monitored at once. |
| | | 2275 | .It Ev PATH |
| | | 2276 | The default search path for executables. |
| | | 2277 | See the |
| | | 2278 | .Sx Path Search |
| | | 2279 | section above. |
2031 | .It Ev PS1 | | 2280 | .It Ev PS1 |
2032 | The primary prompt string, which defaults to | | 2281 | The primary prompt string, which defaults to |
2033 | .Dq $ \ , | | 2282 | .Dq $ \ , |
2034 | unless you are the superuser, in which case it defaults to | | 2283 | unless you are the superuser, in which case it defaults to |
2035 | .Dq # \ . | | 2284 | .Dq # \ . |
2036 | .It Ev PS2 | | 2285 | .It Ev PS2 |
2037 | The secondary prompt string, which defaults to | | 2286 | The secondary prompt string, which defaults to |
2038 | .Dq \*[Gt] \ . | | 2287 | .Dq \*[Gt] \ . |
2039 | .It Ev PS4 | | 2288 | .It Ev PS4 |
2040 | Output before each line when execution trace (set -x) is enabled, | | 2289 | Output before each line when execution trace (set -x) is enabled, |
2041 | defaults to | | 2290 | defaults to |
2042 | .Dq + \ . | | 2291 | .Dq + \ . |
2043 | .It Ev IFS | | | |
2044 | Input Field Separators. | | | |
2045 | This is normally set to | | | |
2046 | .Aq space , | | | |
2047 | .Aq tab , | | | |
2048 | and | | | |
2049 | .Aq newline . | | | |
2050 | See the | | | |
2051 | .Sx White Space Splitting | | | |
2052 | section for more details. | | | |
2053 | .It Ev TERM | | 2292 | .It Ev TERM |
2054 | The default terminal setting for the shell. | | 2293 | The default terminal setting for the shell. |
2055 | This is inherited by | | 2294 | This is inherited by |
2056 | children of the shell, and is used in the history editing modes. | | 2295 | children of the shell, and is used in the history editing modes. |
2057 | .It Ev HISTSIZE | | 2296 | .\" This is explicitly last, not in sort order - please leave! |
2058 | The number of lines in the history buffer for the shell. | | 2297 | .It Ev NETBSD_SHELL |
| | | 2298 | Unlike the variables mentioned above, |
| | | 2299 | this variable is somewhat strange, |
| | | 2300 | in that it cannot be set, |
| | | 2301 | inherited from the environment, |
| | | 2302 | modified, or exported from the shell. |
| | | 2303 | If set, it indicates that the shell is the |
| | | 2304 | .Ic sh |
| | | 2305 | defined by this manual page, and gives its version information. |
| | | 2306 | It behaves like any other variable that has the read-only |
| | | 2307 | and un-exportable attributes set. |
2059 | .El | | 2308 | .El |
2060 | .Sh FILES | | 2309 | .Sh FILES |
2061 | .Bl -item | | 2310 | .Bl -item |
2062 | .It | | 2311 | .It |
2063 | .Pa $HOME/.profile | | 2312 | .Pa $HOME/.profile |
2064 | .It | | 2313 | .It |
2065 | .Pa /etc/profile | | 2314 | .Pa /etc/profile |
2066 | .El | | 2315 | .El |
2067 | .Sh EXIT STATUS | | 2316 | .Sh EXIT STATUS |
2068 | Errors that are detected by the shell, such as a syntax error, will cause the | | 2317 | Errors that are detected by the shell, such as a syntax error, will cause the |
2069 | shell to exit with a non-zero exit status. | | 2318 | shell to exit with a non-zero exit status. |
2070 | If the shell is not an | | 2319 | If the shell is not an |
2071 | interactive shell, the execution of the shell file will be aborted. | | 2320 | interactive shell, the execution of the shell file will be aborted. |
| @@ -2095,13 +2344,15 @@ A | | | @@ -2095,13 +2344,15 @@ A |
2095 | command appeared in | | 2344 | command appeared in |
2096 | .At v1 . | | 2345 | .At v1 . |
2097 | It was, however, unmaintainable so we wrote this one. | | 2346 | It was, however, unmaintainable so we wrote this one. |
2098 | .Sh BUGS | | 2347 | .Sh BUGS |
2099 | Setuid shell scripts should be avoided at all costs, as they are a | | 2348 | Setuid shell scripts should be avoided at all costs, as they are a |
2100 | significant security risk. | | 2349 | significant security risk. |
2101 | .Pp | | 2350 | .Pp |
2102 | PS1, PS2, and PS4 should be subject to parameter expansion before | | 2351 | PS1, PS2, and PS4 should be subject to parameter expansion before |
2103 | being displayed. | | 2352 | being displayed. |
2104 | .Pp | | 2353 | .Pp |
2105 | The characters generated by filename completion should probably be quoted | | 2354 | The characters generated by filename completion should probably be quoted |
2106 | to ensure that the filename is still valid after the input line has been | | 2355 | to ensure that the filename is still valid after the input line has been |
2107 | processed. | | 2356 | processed. |
| | | 2357 | .Pp |
| | | 2358 | Many, many, more. |