neulab/tldr huggingface dataset:
A pattern of the form %(pattern-pair(s)) is a sub-pattern that can be used to match nested character expressions.  Each pattern-pair is a two character sequence which cannot contain & or ⎪.  The first pattern-pair specifies the starting and ending characters for the match.  Each subsequent pattern-pair represents the beginning and ending characters of a nested group that will be skipped over when counting starting and ending character matches.  The behavior is unspecified when the first character of a pattern-pair is alpha-numeric except for the following: D      Causes the ending character to terminate the search for this pattern without finding a match. E      Causes the ending character to be interpreted as an escape character. L      Causes the ending character to be interpreted as a quote character causing all characters to be ignored when looking for a match. Q      Causes the ending character to be interpreted as a quote character causing all characters other than any escape character to be ignored when looking for a match. Thus, %({}Q"E\), matches characters starting at { until the matching } is found not counting any { or } that is inside a double quoted string or preceded by the escape character \.  Without the {} this pattern matches any C language string.
Each sub-pattern in a composite pattern is numbered, starting at 1, by the location of the ( within the pattern.  The sequence \n, where n is a single digit and \n comes after the n-th. sub-pattern, matches the same string as the sub-pattern itself.
Finally a pattern can contain sub-patterns of the form ∼(options:pattern- list), where either options or :pattern-list can be omitted.  Unlike the other compound patterns, these sub-patterns are not counted in the numbered sub-patterns.  :pattern-list must be omitted for options F, G, N , and V below.  If options is present, it can consist of one or more of the following: +      Enable the following options.  This is the default. -      Disable the following options. E      The remainder of the pattern uses extended regular expression syntax like the egrep(1) command. F      The remainder of the pattern uses fgrep(1) expression syntax. G      The remainder of the pattern uses basic regular expression syntax like the grep(1) command. K      The remainder of the pattern uses shell pattern syntax. This is the default. N      This is ignored.  However, when it is the first letter and is used with file name generation, and no matches occur, the file pattern expands to the empty string. X      The remainder of the pattern uses augmented regular expression syntax like the xgrep(1) command. P      The remainder of the pattern uses perl(1) regular expression syntax.  Not all perl regular expression syntax is currently implemented. V      The remainder of the pattern uses System V regular expression syntax. i      Treat the match as case insensitive. g      File the longest match (greedy).  This is the default. l      Left anchor the pattern.  This is the default for K style patterns. r      Right anchor the pattern.  This is the default for K style patterns. If both options and :pattern-list are specified, then the options apply only to  pattern-list.  Otherwise, these options remain in effect until they are disabled by a subsequent ∼(...) or at the end of the sub-pattern containing ∼(...).
Quoting. Each of the metacharacters listed earlier (see Definitions above) has a special meaning to the shell and causes termination of a word unless quoted.  A character may be quoted (i.e., made to stand for itself) by preceding it with a \.  The pair \new-line is removed.  All characters enclosed between a pair of single quote marks (′′) that is not preceded by a $ are quoted.  A single quote cannot appear within the single quotes.  A single quoted string preceded by an unquoted $ is processed as an ANSI-C string except for the following: \0     Causes the remainder of the string to be ignored. \E     Equivalent to the escape character (ascii 033), \e     Equivalent to the escape character (ascii 033), \cx    Expands to the character control-x. \C[.name.] Expands to the collating element name.
Inside double quote marks (""), parameter and command substitution occur and \ quotes the characters \, `, ", and $.  A $ in front of a double quoted string will be ignored in the "C" or "POSIX" locale, and may cause the string to be replaced by a locale specific string otherwise.  The meaning of $* and $@ is identical when not quoted or when used as a variable assignment value or as a file name.  However, when used as a command argument, "$*" is equivalent to "$1d$2d...", where d is the first character of the IFS variable, whereas "$@" is equivalent to "$1" "$2" ....  Inside grave quote marks (``), \ quotes the characters \, `, and $. If the grave quotes occur within double quotes, then \ also quotes the character ".
The special meaning of reserved words or aliases can be removed by quoting any character of the reserved word.  The recognition of function names or built-in command names listed below cannot be altered by quoting them.
Arithmetic Evaluation. The shell performs arithmetic evaluation for arithmetic substitution, to evaluate an arithmetic command, to evaluate an indexed array subscript, and to evaluate arguments to the built-in commands shift and let. Evaluations are performed using double precision floating point arithmetic or long double precision floating point for systems that provide this data type.  Floating point constants follow the ANSI-C programming language floating point conventions.  The floating point constants Nan and Inf can be use to represent "not a number" and infinity respectively.  Integer constants follow the ANSI-C programming language integer constant conventions although only single byte character constants are recognized and character casts are not recognized.  In addition constants can be of the form [base#]n where base is a decimal number between two and sixty-four representing the arithmetic base and n is a number in that base.  The digits above 9 are represented by the lower case letters, the upper case letters, @, and _ respectively.  For bases less than or equal to 36, upper and lower case characters can be used interchangeably.
An arithmetic expression uses the same syntax, precedence, and associativity of expression as the C language.  All the C language operators that apply to floating point quantities can be used.  In addition, the operator ** can be used for exponentiation.  It has higher precedence than multiplication and is left associative.  In addition, when the value of an arithmetic variable or sub-expression can be represented as a long integer, all C language integer arithmetic operations can be performed.  Variables can be referenced by name within an arithmetic expression without using the parameter expansion syntax. When a variable is referenced, its value is evaluated as an arithmetic expression.
Any of the following math library functions that are in the C math library can be used within an arithmetic expression:
abs acos acosh asin asinh atan atan2 atanh cbrt ceil copysign cos cosh erf erfc exp exp2 expm1 fabs fdim finite floor fma fmax fmin fmod hypot ilogb int isfinite sinf isnan isnormal issubnormal issubordered iszero j0 j1 jn lgamma log log10 log2 logb nearbyint pow remainder rint round scanb signbit sin sinh sqrt tan tanh tgamma trunc y0 y1 yn In addition, arithmetic functions can be defined as shell functions with a variant of the function name syntax,
function .sh.math.name ident ... { list ;} where name is the function name used in the arithmetic expression. If the calling argument corresponding to ident is the name of an array variable, then ident is a name reference to this array. Otherwise, ident is a reference to long double precision floating point variable containing the value from the caller.  The value of .sh.value when the function returns is the value of this function. User defined functions can take up to 3 arguments and override C math library functions.
An internal representation of a variable as a double precision floating point can be specified with the -E [n], -F [n], or -X [n] option of the typeset special built-in command.  The -E option causes the expansion of the value to be represented using scientific notation when it is expanded.  The optional option argument n defines the number of significant figures.  The -F option causes the expansion to be represented as a floating decimal number when it is expanded.  The -X option cause the expansion to be represented using the %a format defined by ISO C-99.  The optional option argument n defines the number of places after the decimal (or radix) point in this case.
An internal integer representation of a variable can be specified with the -i [n] option of the typeset special built-in command.  The optional option argument n specifies an arithmetic base to be used when expanding the variable.  If you do not specify an arithmetic base, base 10 will be used.
Arithmetic evaluation is performed on the value of each assignment to a variable with the -E, -F, -X, or -i attribute.  Assigning a floating point number to a variable whose type is an integer causes the fractional part to be truncated.
Inside an arithmetic expression, all integer and floating point variables can be following by .MIN, .MAX, or .DIG to give the maximum value, mininum value, or number of significant digits for variables of that type.
Floating point variables can be also followed by .INT_MAX or .INT_MIN to give the largest or smallest integers represented by that type.
Floating point variables can also be followed by .EPSILON to give the distance to the next floating point number of that type.  Floating point variables can be followed by MAX_10_EXP to give the maximum base 10 exponent that can be represented by that type.
Inside an arithmetic expression, the following constants are recongnized and are of type typeset-lE. NaN    Not a number.  It is case insensitive. Inf    Infinity.  It is case insensitive. E PI 1_PI   1.0/PI. 2_PI   2.0/PI. PI_2   PI/2.0 PI_4   PI/4.0. SQRTPI sqrt(PI). SQRT2  sqrt(2.0). SQRT1_2 sqrt(1./2.) LOGE   log(E) LOG10E log10(E) LN2    log(2.0) LOG2E  log2(E)
Array Sorting. The -s option of the set built-in command can be used to sort its arguments or to sort indexed arrays, indexed arrays of compound variables, and indexed arrays of types (see "Type Variables" section below).  By default the sort order is defined by the current locale.  For compound variables and for types, the -K option for set can be followed by a comma separated list of sub-fields to sort on.  Each field can be followed by a : and the letter n for numerical sorting and/or r for reverse sorting.  For an plain indexed array the -K option can be followed by :n and  :r for numerical or reverse sorting.
Prompting. When used interactively, the shell prompts with the value of PS1 after expanding it for parameter expansion, command substitution, and arithmetic substitution, before reading a command.  In addition, each single !  in the prompt is replaced by the command number.  A !!  is required to place !  in the prompt.  If at any time a new-line is typed and further input is needed to complete a command, then the secondary prompt (i.e., the value of PS2) is issued.
In each of the above expressions, if file is of the form /dev/fd/n, where n is an integer, then the test is applied to the open file whose descriptor number is n.
A compound expression can be constructed from these primitives by using any of the following, listed in decreasing order of precedence. (expression) True, if expression is true.  Used to group expressions. ! expression True if expression is false. expression1 && expression2 True, if expression1 and expression2 are both true. expression1 ⎪⎪ expression2 True, if either expression1 or expression2 is true.
Input/Output. Before a command is executed, its input and output may be redirected using a special notation interpreted by the shell.  The following may appear anywhere in a simple-command or may precede or follow a command and are not passed on to the invoked command.  Command substitution, parameter expansion, and arithmetic substitution occur before word or digit is used except as noted below.  File name generation occurs only if the shell is interactive and the pattern matches a single file.  Field splitting is not performed.
In each of the following redirections, if file is of the form /dev/sctp/host/port, /dev/tcp/host/port, or /dev/udp/host/port, where host is a hostname or host address, and port is a service given by name or an integer port number, then the redirection attempts to make a tcp, sctp or udp connection to the corresponding socket.
No intervening space is allowed between the characters of redirection operators.
<word         Use file word as standard input (file descriptor 0).
>word         Use file word as standard output (file descriptor 1).  If the file does not exist then it is created.  If the file exists, and the noclobber option is on, this causes an error; otherwise, it is truncated to zero length.
>|word        Same as >, except that it overrides the noclobber option.
>;word        Write output to a temporary file.  If the command completes successfully rename it to word, otherwise, delete the temporary file.  >;word cannot be used with the exec(2). built-in.
>>word        Use file word as standard output.  If the file exists, then output is appended to it (by first seeking to the end-of- file); otherwise, the file is created.
<>word        Open file word for reading and writing as standard input.
<>;word       The same as <>word except that if the command completes successfully, word is truncated to the offset at command completion.  <>;word cannot be used with the exec(2). built-in.
<<[-]word     The shell input is read up to a line that is the same as word after any quoting has been removed, or to an end-of- file.  No parameter substitution, command substitution, arithmetic substitution or file name generation is performed on word.  The resulting document, called a here- document, becomes the standard input.  If any character of word is quoted, then no interpretation is placed upon the characters of the document; otherwise, parameter expansion, command substitution, and arithmetic substitution occur, \new-line is ignored, and \ must be used to quote the characters \, $, `.  If - is appended to <<, then all leading tabs are stripped from word and from the document. If # is appended to <<, then leading spaces and tabs will be stripped off the first line of the document and up to an equivalent indentation will be stripped from the remaining lines and from word.  A tab stop is assumed to occur at every 8 columns for the purposes of determining the indentation.
<<<word       A short form of here document in which word becomes the contents of the here-document after any parameter expansion, command substitution, and arithmetic substitution occur.
<&digit       The standard input is duplicated from file descriptor digit (see dup(2)).  Similarly for the standard output using >&digit.
<&digit-      The file descriptor given by digit is moved to standard input.  Similarly for the standard output using >&digit-.
<&-           The standard input is closed.  Similarly for the standard output using >&-.
<&p           The input from the co-process is moved to standard input.
>&p           The output to the co-process is moved to standard output.
<#((expr))    Evaluate arithmetic expression expr and position file descriptor 0 to the resulting value bytes from the start of the file.  The variables CUR and EOF evaluate to the current offset and end-of-file offset respectively when evaluating expr.
>#((offset))  The same as <# except applies to file descriptor 1.
<#pattern     Seeks forward to the beginning of the next line containing pattern.
<##pattern    The same as <# except that the portion of the file that is skipped is copied to standard output.
If one of the above is preceded by a digit, with no intervening space, then the file descriptor number referred to is that specified by the digit (instead of the default 0 or 1).  If one of the above, other than >&- and the ># and <# forms, is preceded by {varname} with no intervening space, then a file descriptor number > 10 will be selected by the shell and stored in the variable varname.  If >&- or the any of the ># and <# forms is preceded by {varname} the value of varname defines the file descriptor to close or position.  For example:
... 2>&1
means file descriptor 2 is to be opened for writing as a duplicate of file descriptor 1 and
exec {n}<file
means open file named file for reading and store the file descriptor number in variable n.
The order in which redirections are specified is significant.  The shell evaluates each redirection in terms of the (file descriptor, file) association at the time of evaluation.  For example:
... 1>fname 2>&1
first associates file descriptor 1 with file fname.  It then associates file descriptor 2 with the file associated with file descriptor 1 (i.e. fname).  If the order of redirections were reversed, file descriptor 2 would be associated with the terminal (assuming file descriptor 1 had been) and then file descriptor 1 would be associated with file fname.
If a command is followed by & and job control is not active, then the default standard input for the command is the empty file /dev/null. Otherwise, the environment for the execution of a command contains the file descriptors of the invoking shell as modified by input/output specifications.
Environment. The environment (see environ(7)) is a list of name-value pairs that is passed to an executed program in the same way as a normal argument list. The names must be identifiers and the values are character strings.  The shell interacts with the environment in several ways.  On invocation, the shell scans the environment and creates a variable for each name found, giving it the corresponding value and attributes and marking it export. Executed commands inherit the environment.  If the user modifies the values of these variables or creates new ones, using the export or typeset -x commands, they become part of the environment.  The environment seen by any executed command is thus composed of any name- value pairs originally inherited by the shell, whose values may be modified by the current shell, plus any additions which must be noted in export or typeset -x commands.
The environment for any simple-command or function may be augmented by prefixing it with one or more variable assignments.  A variable assignment argument is a word of the form identifier=value.  Thus:
TERM=450 cmd args                  and (export TERM; TERM=450; cmd args)
are equivalent (as far as the above execution of cmd is concerned except for special built-in commands listed below - those that are preceded with a dagger).
If the obsolete -k option is set, all variable assignment arguments are placed in the environment, even if they occur after the command name. The following first prints a=b c and then c:
echo a=b c set -k echo a=b c This feature is intended for use with scripts written for early versions of the shell and its use in new scripts is strongly discouraged.  It is likely to disappear someday.
Functions. For historical reasons, there are two ways to define functions, the name() syntax and the function name syntax, described in the Commands section above.  Shell functions are read in and stored internally.  Alias names are resolved when the function is read.  Functions are executed like commands with the arguments passed as positional parameters.  (See Execution below.)
Functions defined by the function name syntax and called by name execute in the same process as the caller and share all files and present working directory with the caller.  Traps caught by the caller are reset to their default action inside the function.  A trap condition that is not caught or ignored by the function causes the function to terminate and the condition to be passed on to the caller.  A trap on EXIT set inside a function is executed in the environment of the caller after the function completes.  Ordinarily, variables are shared between the calling program and the function.  However, the typeset special built-in command used within a function defines local variables whose scope includes the current function.  They can be passed to functions that they call in the variable assignment list that precedes the call or as arguments passed as name references.  Errors within functions return control to the caller.
Functions defined with the name() syntax and functions defined with the function name syntax that are invoked with the .  special built-in are executed in the caller's environment and share all variables and traps with the caller.  Errors within these function executions cause the script that contains them to abort.
The special built-in command return is used to return from function calls.
Function names can be listed with the -f or +f option of the typeset special built-in command.  The text of functions, when available, will also be listed with -f.  Functions can be undefined with the -f option of the unset special built-in command.
Ordinarily, functions are unset when the shell executes a shell script. Functions that need to be defined across separate invocations of the shell should be placed in a directory and the FPATH variable should contain the name of this directory.  They may also be specified in the ENV file.
Discipline Functions. Each variable can have zero or more discipline functions associated with it.  The shell initially understands the discipline names get, set, append, and unset but can be added when defining new types.  On most systems others can be added at run time via the C programming interface extension provided by the builtin built-in utility.  If the get discipline is defined for a variable, it is invoked whenever the given variable is referenced.  If the variable .sh.value is assigned a value inside the discipline function, the referenced variable will evaluate to this value instead.  If the set discipline is defined for a variable, it is invoked whenever the given variable is assigned a value.  If the append discipline is defined for a variable, it is invoked whenever a value is appended to the given variable.  The variable .sh.value is given the value of the variable before invoking the discipline, and the variable will be assigned the value of .sh.value after the discipline completes.  If .sh.value is unset inside the discipline, then that value is unchanged.  If the unset discipline is defined for a variable, it is invoked whenever the given variable is unset.  The variable will not be unset unless it is unset explicitly from within this discipline function.
The variable .sh.name contains the name of the variable for which the discipline function is called, .sh.subscript is the subscript of the variable, and .sh.value will contain the value being assigned inside the set discipline function.  The variable _ is a reference to the variable including the subscript if any.  For the set discipline, changing .sh.value will change the value that gets assigned.  Finally, the expansion ${var.name}, when name is the name of a discipline, and there is no variable of this name, is equivalent to the command substitution ${ var.name;}.
Name Spaces. Commands and functions that are executed as part of the list of a namespace command that modify variables or create new ones, create a new variable whose name is the name of the name space as given by identifier preceded by ..  When a variable whose name is name is referenced, it is first searched for using .identifier.name.  Similarly, a function defined by a command in the namespace list is created using the name space name preceded by a ..
When  the list of a namespace command contains a namespace command, the names of variables and functions that are created consist of the variable or function name preceded by the list of identifiers each preceded by ..
Outside of a name space, a variable or function created inside a name space can be referenced by preceding it with the name space name.
By default, variables staring with .sh are in the sh name space.
Type Variables. Typed variables provide a way to create data structure and objects.  A type can be defined either by a shared library, by the enum built-in command described below, or by using the new -T option of the typeset built-in command.  With the -T option of typeset, the type name, specified as an option argument to -T, is set with a compound variable assignment that defines the type.  Function definitions can appear inside the compound variable assignment and these become discipline functions for this type and can be invoked or redefined by each instance of the type.  The function name create is treated specially.  It is invoked for each instance of the type that is created but is not inherited and cannot be redefined for each instance.
When a type is defined a special built-in command of that name is added. These built-ins are declaration commands and follow the same expansion rules as all the special built-in commands defined below that are preceded by ††.  These commands can subsequently be used inside further type definitions.  The man page for these commands can be generated by using the --man option or any of the other -- options described with getopts.  The -r, -a, -A, -h, and -S options of typeset are permitted with each of these new built-ins.
An instance of a type is created by invoking the type name followed by one or more instance names.  Each instance of the type is initialized with a copy of the sub-variables except for sub-variables that are defined with the -S option.  Variables defined with the -S are shared by all instances of the type.  Each instance can change the value of any sub-variable and can also define new discipline functions of the same names as those defined by the type definition as well as any standard discipline names.  No additional sub-variables can be defined for any instance.
When defining a type, if the value of a sub-variable is not set and the -r attribute is specified, it causes the sub-variable to be a required sub-variable.  Whenever an instance of a type is created, all required sub-variables must be specified.  These sub-variables become readonly in each instance.
When unset is invoked on a sub-variable within a type, and the -r attribute has not been specified for this field, the value is reset to the default value associative with the type.  Invoking unset on a type instance not contained within another type deletes all sub-variables and the variable itself.
A type definition can be derived from another type definition by defining the first sub-variable name as _ and defining its type as the base type. Any remaining definitions will be additions and modifications that apply to the new type.  If the new type name is the same as that of the base type, the type will be replaced and the original type will no longer be accessible.
The typeset command with the -T and no option argument or operands will write all the type definitions to standard output in a form that can be read in to create all the types.
Jobs. If the monitor option of the set command is turned on, an interactive shell associates a job with each pipeline.  It keeps a table of current jobs, printed by the jobs command, and assigns them small integer numbers.  When a job is started asynchronously with &, the shell prints a line which looks like:
[1] 1234
indicating that the job which was started asynchronously was job number 1 and had one (top-level) process, whose process id was 1234.
This paragraph and the next require features that are not in all versions of UNIX and may not apply.  If you are running a job and wish to do something else you may hit the key ^Z (control-Z) which sends a STOP signal to the current job.  The shell will then normally indicate that the job has been `Stopped', and print another prompt.  You can then manipulate the state of this job, putting it in the background with the bg command, or run some other commands and then eventually bring the job back into the foreground with the foreground command fg.  A ^Z takes effect immediately and is like an interrupt in that pending output and unread input are discarded when it is typed.
A job being run in the background will stop if it tries to read from the terminal.  Background jobs are normally allowed to produce output, but this can be disabled by giving the command stty tostop.  If you set this tty option, then background jobs will stop when they try to produce output like they do when they try to read input.
A job pool is a collection of jobs started with list & associated with a name.
There are several ways to refer to jobs in the shell.  A job can be referred to by the process id of any process of the job or by one of the following: %number The job with the given number. pool   All the jobs in the job pool named by pool. pool.number The job number number in the job pool named by pool. %string Any job whose command line begins with string. %?string Any job whose command line contains string. %%     Current job. %+     Equivalent to %%. %-     Previous job.  In addition, unless noted otherwise, wherever a job can be specified, the name of a background job pool can be used to represent all the jobs in that pool.
The shell learns immediately whenever a process changes state.  It normally informs you whenever a job becomes blocked so that no further progress is possible, but only just before it prints a prompt.  This is done so that it does not otherwise disturb your work.  The notify option of the set command causes the shell to print these job change messages as soon as they occur.
When the monitor option is on, each background job that completes triggers any trap set for CHLD.
When you try to leave the shell while jobs are running or stopped, you will be warned that `You have stopped(running) jobs.'  You may use the jobs command to see what they are.  If you immediately try to exit again, the shell will not warn you a second time, and the stopped jobs will be terminated.  When a login shell receives a HUP signal, it sends a HUP signal to each job that has not been disowned with the disown built-in command described below.
Signals. The INT and QUIT signals for an invoked command are ignored if the command is followed by & and the monitor option is active.  Otherwise, signals have the values inherited by the shell from its parent (but see also the trap built-in command below).
Execution. Each time a command is read, the above substitutions are carried out.  If the command name matches one of the Special Built-in Commands listed below, it is executed within the current shell process.  Next, the command name is checked to see if it matches a user defined function.  If it does, the positional parameters are saved and then reset to the arguments of the function call.  A function is also executed in the current shell process.  When the function completes or issues a return, the positional parameter list is restored.  For functions defined with the function name syntax, any trap set on EXIT within the function is executed.  The exit value of a function is the value of the last command executed.  If a command name is not a special built-in command or a user defined function, but it is one of the built-in commands listed below, it is executed in the current shell process.
The shell variables PATH followed by the variable FPATH defines the list of directories to search for the command name.  Alternative directory names are separated by a colon (:).  The default path is equal to getconf PATH output.  The current directory can be specified by two or more adjacent colons, or by a colon at the beginning or end of the path list.  If the command name contains a /, then the search path is not used.  Otherwise, each directory in the list of directories defined by PATH and FPATH is checked in order.  If the directory being searched is contained in FPATH and contains a file whose name matches the command being searched, then this file is loaded into the current shell environment as if it were the argument to the . command except that only preset aliases are expanded, and a function of the given name is executed as described above.
If this directory is not in FPATH the shell first determines whether there is a built-in version of a command corresponding to a given pathname and if so it is invoked in the current process.  If no built-in is found, the shell checks for a file named .paths in this directory.  If found and there is a line of the form FPATH=path where path names an existing directory then that directory is searched immediately after the current directory as if it were found in the FPATH variable.  If path does not begin with /, it is checked for relative to the directory being searched.
The .paths file is then checked  for a line of the form PLUGIN_LIB=libname [ : libname ] ... .  Each library named by libname will be searched for as if it were an option argument to builtin -f, and if it contains a built-in of the specified name this will be executed instead of a command by this name.  Any built-in loaded from a library found this way will be associated with the directory containing the .paths file so it will only execute if not found in an earlier directory.
Finally, the directory will be checked for a file of the given name.  If the file has execute permission but is not an a.out file, it is assumed to be a file containing shell commands.  A separate shell is spawned to read it.  All non-exported variables are removed in this case.  If the shell command file doesn't have read permission, or if the setuid and/or setgid bits are set on the file, then the shell executes an agent whose job it is to set up the permissions and execute the shell with the shell command file passed down as an open file.  If the .paths contains a line of the form name=value in the first or second line, then the environment variable name is modified by prepending the directory specified by value to the directory list.  If value is not an absolute directory, then it specifies a directory relative to the directory that the executable was found.  If the environment variable name does not already exist it will be added to the environment list for the specified command.  A parenthesized command is executed in a sub-shell without removing non- exported variables.
Command Re-entry. The text of the last HISTSIZE (default 512) commands entered from a terminal device is saved in a history file.  The file $HOME/.sh_history is used if the HISTFILE variable is not set or if the file it names is not writable.  A shell can access the commands of all interactive shells which use the same named HISTFILE.  The built-in command hist is used to list or edit a portion of this file.  The portion of the file to be edited or listed can be selected by number or by giving the first character or characters of the command.  A single command or range of commands can be specified.  If you do not specify an editor program as an argument to hist then the value of the variable HISTEDIT is used.  If HISTEDIT is unset, the obsolete variable FCEDIT is used.  If FCEDIT is not defined, then /bin/ed is used.  The edited command(s) is printed and re-executed upon leaving the editor unless you quit without writing.  The -s option (and in obsolete versions, the editor name -) is used to skip the editing phase and to re-execute the command.  In this case a substitution parameter of the form old=new can be used to modify the command before execution.  For example, with the preset alias r, which is aliased to ′hist -s′, typing `r bad=good c' will re-execute the most recent command which starts with the letter c, replacing the first occurrence of the string bad with the string good.
In-line Editing Options. Normally, each command line entered from a terminal device is simply typed followed by a new-line (`RETURN' or `LINE FEED').  If either the emacs, gmacs, or vi option is active, the user can edit the command line. To be in either of these edit modes set the corresponding option.  An editing option is automatically selected each time the VISUAL or EDITOR variable is assigned a value ending in either of these option names.
The editing features require that the user's terminal accept `RETURN' as carriage return without line feed and that a space (` ') must overwrite the current character on the screen.
Unless the multiline option is on, the editing modes implement a concept where the user is looking through a window at the current line.  The window width is the value of COLUMNS if it is defined, otherwise 80.  If the window width is too small to display the prompt and leave at least 8 columns to enter input, the prompt is truncated from the left.  If the line is longer than the window width minus two, a mark is displayed at the end of the window to notify the user.  As the cursor moves and reaches the window boundaries the window will be centered about the cursor.  The mark is a > (<, *) if the line extends on the right (left, both) side(s) of the window.
The search commands in each edit mode provide access to the history file. Only strings are matched, not patterns, although a leading ^ in the string restricts the match to begin at the first character in the line.
Each of the edit modes has an operation to list the files or commands that match a partially entered word.  When applied to the first word on the line, or the first word after a ;, ⎪, &, or (, and the word does not begin with ∼ or contain a /, the list of aliases, functions, and executable commands defined by the PATH variable that could match the partial word is displayed.  Otherwise, the list of files that match the given word is displayed.  If the partially entered word does not contain any file expansion characters, a * is appended before generating these lists.  After displaying the generated list, the input line is redrawn. These operations are called command name listing and file name listing, respectively.  There are additional operations, referred to as command name completion and file name completion, which compute the list of matching commands or files, but instead of printing the list, replace the current word with a complete or partial match.  For file name completion, if the match is unique, a / is appended if the file is a directory and a space is appended if the file is not a directory.  Otherwise, the longest common prefix for all the matching files replaces the word.  For command name completion, only the portion of the file names after the last / are used to find the longest command prefix.  If only a single name matches this prefix, then the word is replaced with the command name followed by a space.  When using a tab for completion that does not yield a unique match, a subsequent tab will provide a numbered list of matching alternatives.  A specific selection can be made by entering the selection number followed by a tab.
Key Bindings. The KEYBD trap can be used to intercept keys as they are typed and change the characters that are actually seen by the shell.  This trap is executed after each character (or sequence of characters when the first character is ESC) is entered while reading from a terminal.  The variable .sh.edchar contains the character or character sequence which generated the trap.  Changing the value of .sh.edchar in the trap action causes the shell to behave as if the new value were entered from the keyboard rather than the original value.
The variable .sh.edcol is set to the input column number of the cursor at the time of the input.  The variable .sh.edmode is set to ESC when in vi insert mode (see below) and is null otherwise.  By prepending ${.sh.editmode} to a value assigned to .sh.edchar it will cause the shell to change to control mode if it is not already in this mode.
This trap is not invoked for characters entered as arguments to editing directives, or while reading input for a character search.
Emacs Editing Mode. This mode is entered by enabling either the emacs or gmacs option.  The only difference between these two modes is the way they handle ^T.  To edit, the user moves the cursor to the point needing correction and then inserts or deletes characters or words as needed.  All the editing commands are control characters or escape sequences.  The notation for control characters is caret (^) followed by the character.  For example, ^F is the notation for control F.  This is entered by depressing `f' while holding down the `CTRL' (control) key.  The `SHIFT' key is not depressed.  (The notation ^?  indicates the DEL (delete) key.)
The notation for escape sequences is M- followed by a character.  For example, M-f (pronounced Meta f) is entered by depressing ESC (ascii 033) followed by `f'.  (M-F would be the notation for ESC followed by `SHIFT' (capital) `F'.)
All edit commands operate from any place on the line (not just at the beginning).  Neither the `RETURN' nor the `LINE FEED' key is entered after edit commands except when noted.
Vi Editing Mode. There are two typing modes.  Initially, when you enter a command you are in the input mode.  To edit, the user enters control mode by typing ESC (033) and moves the cursor to the point needing correction and then inserts or deletes characters or words as needed.  Most control commands accept an optional repeat count prior to the command.
When in vi mode on most systems, canonical processing is initially enabled and the command will be echoed again if the speed is 1200 baud or greater and it contains any control characters or less than one second has elapsed since the prompt was printed.  The ESC character terminates canonical processing for the remainder of the command and the user can then modify the command line.  This scheme has the advantages of canonical processing with the type-ahead echoing of raw mode.
If the option viraw is also set, the terminal will always have canonical processing disabled.  This mode is implicit for systems that do not support two alternate end of line delimiters, and may be helpful for certain terminals.
Programmable Completion. By default, hitting the tab key causes the current word to be matched against files starting with the characters you typed and adding as many characters that provide a unique match.  If the matching prefix is not unique hitting tab again will output a numbered list with the choices and entering number tab will replace the current word with that selection.
Programmable completion allows you to control how words are expanded when you enter the tab key for one or more specified commands.  The complete built-in command allows you to specify how to complete the current word of the specified command.
Built-in Commands. The following simple-commands are executed in the shell process. Input/Output redirection is permitted.  Unless otherwise indicated, the output is written on file descriptor 1 and the exit status, when there is no syntax error, is zero.  Except for :, true, false, echo, newgrp, and login, all built-in commands accept -- to indicate end of options.  They also interpret the option --man as a request to display the man page onto standard error and -?  as a help request which prints a usage message on standard error.  Commands that are preceded by one or two † symbols are special built-in commands and are treated specially in the following ways: 1.     Variable assignment lists preceding the command remain in effect when the command completes. 2.     I/O redirections are processed after variable assignments. 3.     Errors cause a script that contains them to abort. 4.     They are not valid function names. 5.     Words following a command preceded by †† that are in the format of a variable assignment are expanded with the same rules as a variable assignment.  This means that tilde substitution is performed after the = sign and field splitting and file name generation are not performed.  These are called declaration built- ins.
† : [ arg ... ] The command only expands parameters.
† . name [ arg ... ] If name is a function defined with the function name reserved word syntax, the function is executed in the current environment (as if it had been defined with the name() syntax.)  Otherwise if name refers to a file, the file is read in its entirety and the commands are executed in the current shell environment.  The search path specified by PATH is used to find the directory containing the file.  If any arguments arg are given, they become the positional parameters while processing the .  command and the original positional parameters are restored upon completion. Otherwise the positional parameters are unchanged.  The exit status is the exit status of the last command executed.
†† alias [ -ptx ]  [ name[ =value  ] ] ... alias with no arguments prints the list of aliases in the form name=value on standard output.  The -p option causes the word alias to be inserted before each one.  When one or more arguments are given, an alias is defined for each name whose value is given. A trailing space in value causes the next word to be checked for alias substitution.  The obsolete -t option is used to set and list tracked aliases.  The value of a tracked alias is the full pathname corresponding to the given name.  The value becomes undefined when the value of PATH is reset but the alias remains tracked.  Without the -t option, for each name in the argument list for which no value is given, the name and value of the alias is printed.  The obsolete -x option has no effect.  The exit status is non-zero if a name is given, but no value, and no alias has been defined for the name.
bg [ job... ] This command is only on systems that support job control.  Puts each specified job into the background.  The current job is put in the background if job is not specified.  See Jobs for a description of the format of job.
† break [ n ] Exit from the enclosing for, while, until, or select loop, if any. If n is specified, then break n levels.
builtin [ -dsp ] [ -f file ] [ name ... ] If name is not specified, and no -f option is specified, the built-ins are printed on standard output.  The -s option prints only the special built-ins.  Otherwise, each name represents the pathname whose basename is the name of the built-in.  The entry point function name is determined by prepending b_ to the built-in name.  A built-in specified by a pathname will only be executed when that pathname would be found during the path search.  Built- ins found in libraries loaded via the .paths file will be associate with the pathname of the directory containing the .paths file. The ISO C/C++ prototype is b_mycommand(int argc, char *argv[], void *context) for the builtin command mycommand where argv is array an of argc elements and context is an optional pointer to a Shell_t structure as described in <ast/shell.h>. Special built-ins cannot be bound to a pathname or deleted.  The -d option deletes each of the given built-ins.  On systems that support dynamic loading, the -f option names a shared library containing the code for built-ins.  The shared library prefix and/or suffix, which depend on the system, can be omitted.  Once a library is loaded, its symbols become available for subsequent invocations of builtin.  Multiple libraries can be specified with separate invocations of the builtin command.  Libraries are searched in the reverse order in which they are specified.  When a library is loaded, it looks for a function in the library whose name is lib_init() and invokes this function with an argument of 0. The -p causes the output to be in a form of builtin commands that can be used as input to the shell to recreate the current set of builtins.