bash(1)


NAME

bash - GNU Bourne-Again SHell

SYNOPSIS

bash [options] [file]

COPYRIGHT

Bash is Copyright (C) 1989, 1991 by the Free Software Foundation, Inc.

DESCRIPTION

Bash is an sh-compatible command language interpreter that executes commands read from the standard input or from a file. Bash also incorporates useful features from the Korn and C shells (ksh and csh).

Bash is ultimately intended to be a conformant implementation of the IEEE Posix Shell and Tools specification (IEEE Working Group 1003.2).

OPTIONS

In addition to the single-character shell options documented in the description of the set builtin command, bash interprets the following flags when it is invoked:

-c string
If the -c flag is present, then commands are read from string . If there are arguments after the string , they are assigned to the positional parameters, starting with $0 .

-i
If the -i flag is present, the shell is interactive .

-s
If the -s flag is present, or if no arguments remain after option processing, then commands are read from the standard input. This option allows the positional parameters to be set when invoking an interactive shell.

-
A single - signals the end of options and disables further option processing. Any arguments after the - are treated as filenames and arguments. An argument of -- is equivalent to an argument of -.

Bash also interprets a number of multi-character options. These options must appear on the command line before the single-character options to be recognized.

-norc
Do not read and execute the personal initialization file ~/.bashrc if the shell is interactive. This option is on by default if the shell is invoked as sh .

-noprofile
Do not read either the system-wide startup file /etc/profile or any of the personal initialization files ~/.bash_profile , ~/.bash_login , or ~/.profile . By default, bash normally reads these files when it is invoked as a login shell (see INVOCATION below).

-rcfile file
Execute commands from file instead of the standard personal initialization file ~/.bashrc , if the shell is interactive (see INVOCATION below).

-version
Show the version number of this instance of bash when starting.

-quiet
Do not be verbose when starting up (do not show the shell version or any other information). This is the default.

-login
Make bash act as if it had been invoked as a login shell.

-nobraceexpansion
Do not perform curly brace expansion (see Brace Expansion below).

-nolineediting
Do not use the GNU readline library to read command lines if interactive.

-posix
Change the behavior of bash where the default operation differs from the Posix 1003.2 standard to match the standard

ARGUMENTS

If arguments remain after option processing, and neither the -c nor the -s option has been supplied, the first argument is assumed to be the name of a file containing shell commands. If bash is invoked in this fashion, $0 is set to the name of the file, and the positional parameters are set to the remaining arguments. Bash reads and executes commands from this file, then exits. Bash's exit status is the exit status of the last command executed in the script.

DEFINITIONS

blank
A space or tab.

word
A sequence of characters considered as a single unit by the shell. Also known as a token .

name
A word consisting only of alphanumeric characters and underscores, and beginning with an alphabetic character or an underscore. Also referred to as an identifier .

metacharacter
A character that, when unquoted, separates words. One of the following:

| & ; ( ) < > space tab

control operator
A token that performs a control function. It is one of the following symbols:

|| & && ; ;; ( ) | <newline>

RESERVED WORDS

Reserved words are words that have a special meaning to the shell. The following words are recognized as reserved when unquoted and either the first word of a simple command (see SHELL GRAMMAR below) or the third word of a case or for command:

! case do done elif else esac fi for function if in select then until while { }

SHELL GRAMMAR

Simple Commands

A simple command is a sequence of optional variable assignments followed by blank-separated words and redirections, and terminated by a control operator. The first word specifies the command to be executed. The remaining words are passed as arguments to the invoked command.

The return value of a simple command is its exit status, or 128+n if the command is terminated by signal n .

Pipelines

A pipeline is a sequence of one or more commands separated by the character | . The format for a pipeline is:

[ ! ] command [ | command2 ... ]

The standard output of command is connected to the standard input of command2 . This connection is performed before any redirections specified by the command (see REDIRECTION below).

If the reserved word ! precedes a pipeline, the exit status of that pipeline is the logical NOT of the exit status of the last command. Otherwise, the status of the pipeline is the exit status of the last command. The shell waits for all commands in the pipeline to terminate before returning a value.

Each command in a pipeline is executed as a separate process (i.e., in a subshell).

Lists

A list is a sequence of one or more pipelines separated by one of the operators ; , & , && , or || , and terminated by one of ; , & , or <newline> .

Of these list operators, && and || have equal precedence, followed by ; and &, which have equal precedence.

If a command is terminated by the control operator & , the shell executes the command in the background in a subshell. The shell does not wait for the command to finish, and the return status is 0. Commands separated by a ; are executed sequentially; the shell waits for each command to terminate in turn. The return status is the exit status of the last command executed.

The control operators && and || denote AND lists and OR lists, respectively. An AND list has the form

command && command2

command2 is executed if, and only if, command returns an exit status of zero.

An OR list has the form

command || command2

command2 is executed if and only if command returns a non-zero exit status. The return status of AND and OR lists is the exit status of the last command executed in the list.

Compound Commands

A compound command is one of the following:

(list)
list is executed in a subshell. Variable assignments and builtin commands that affect the shell's environment do not remain in effect after the command completes. The return status is the exit status of list.

{ list; }
list is simply executed in the current shell environment. This is known as a group command. The return status is the exit status of list.

for name [ in word; ] do list ; done
The list of words following in is expanded, generating a list of items. The variable name is set to each element of this list in turn, and list is executed each time. If the in word is omitted, the for command executes list once for each positional parameter that is set (see PARAMETERS below).

select name [ in word; ] do list ; done
The list of words following in is expanded, generating a list of items. The set of expanded words is printed on the standard error, each preceded by a number. If the in word is omitted, the positional parameters are printed (see PARAMETERS below). The PS3 prompt is then displayed and a line read from the standard input. If the line consists of the number corresponding to one of the displayed words, then the value of name is set to that word. If the line is empty, the words and prompt are displayed again. If EOF is read, the command completes. Any other value read causes name to be set to null. The line read is saved in the variable REPLY . The list is executed after each selection until a break or return command is executed. The exit status of select is the exit status of the last command executed in list , or zero if no commands were executed.

case word in [ pattern [ | pattern ] ... ) list ;; ] ... esac
A case command first expands word, and tries to match it against each pattern in turn, using the same matching rules as for pathname expansion (see Pathname Expansion below). When a match is found, the corresponding list is executed. After the first match, no subsequent matches are attempted. The exit status is zero if no patterns are matches. Otherwise, it is the exit status of the last command executed in list.

if lista then lista [ elif lista then lista ] ... [ else lista ] fi
Végrehajtja az if utáni listát. Ha annak kilépési státusza 0, akkor végrehajtja a then utáni listát. Egyébként minden elif utáni listát sorban végrehajt, és ha valamelyik kilépési státusza 0, a megfelelõ then utáni listát is végrehajtja, majd befejezi a parancsot. Egyébként az else utáni listát hajtja végre, ha létezik. A kilépési státusz az utolsó végrehajtott parancs kilépési státusza, vagy 0, ha egyetlen feltétel sem teljesült.

while lista do lista done

until lista do lista done
A while parancs folyamatosan végrehajtja a do utáni listát, amíg a while utáni lista 0 kilépési státusszal tér vissza. Az until parancs megegyezik a while paranccsal, kivéve, hogy a feltétel negálódik; a do utáni listát addig hajtja végre, amíg az utolsó parancs az until utáni listában nem-nulla státusszal tér vissza. A while és az until parancsok kilépési státusza az utoljára végrehajtott do utáni lista utolsó parancsának kilépési státusza, vagy 0, ha a do utáni lista egyszer sem hajtódott végre.

[ function ] név () { lista; }
Ez a parancs egy név nevû függvényt definiál. A függvény magja a { és } közötti parancsok listája. Ez a lista hajtódik végre valahányszor a név egyszerû parancsként szerepel. A függvény kilépési státusza a függvény magjában legutoljára végrehajtott parancs kilépési státusza. (Lásd a FUNCTIONS bekezdést lejebb.)

MEGJEGYZÉSEK

Egy nem-párbeszédes shellben - vagy egy párbeszédes shellben, amelyikben a set beépített parancs -o interactive-comments opciójával engedélyeztük - ha egy szó a # karakterrel kezdõdik, akkor a shell a szót és az összes hátralévõ karaktert a sorban figyelmen kívül hagyja. Párbeszédes shell a -o interactive-comments opció bekapcsolása nélkül nem engedélyezi a megjegyzéseket.

IDÉZÕJELEZÉS

Az Idézõjelezést  arra használjuk, hogy a shell ne vegye figyelembe bizonyos karakterek vagy
szavak speciális jelentését. Az idézõjelezést arra is használjuk, hogy ne engedélyezzük speciális karakterek spaciális feldolgozását, hogy a shell a lefoglalt szavakat ne ismerje fel lefoglalt szavaknak, vagy hogy elkerüljük a paraméterek kifejtését.

Minden lejjebb, a DEFINITIONS alatt felsorolt metakarakternek speciális jelentése van a shell számára, és ezeket idézõjelezni kell, hogy saját magukat jelentsék. Háromféle idézõjelezési módszer van : az "escape karakter", a szimpla idézõjel, és a dupla idézõjel.

Egy nem-idézõjelezett fordított perjel (backslash : \ ) az "escape karakter". Az õt követõ karakternek megmarad a saját értéke. Az egyetlen kivétel az <újsor>. Ha egy \<újsor> páros van a szövegben, és a fordított perjel nem áll szimpla idézõjelek között, a \<újsor>-t a shell a sor folytatására való utasításként dolgozza fel (tehát valójában figyelmen kívül hagyja).

Szimpla idézõjelek közé zárt karakterek esetén minden az idézõjelek közé esõ karakternek megmarad a saját értéke. Szimpla idézõjel nem szerepelhet szimpla idézõjelek között, még úgy sem, ha megelõzi egy fordított perjel.

Dupla idézõjelek közé zárt karakterek esetén minden az idézõjelek közé esõ karakternek megmarad a saját értéke, kivéve a $ , ` , és \ karaktereket. A $ és a ` megõrzik a speciális jelentésüket dupla idézõjelek között is. A fordított perjel csak akkor õrzi meg a speciális jelentését, ha a következõ karakterek közül követi valamelyik : $ , ` , " , vagy <újsor>. Dupla idézõjel szerepelhet dupla idézõjelek közt, ha megelõzi egy fordított perjel.

A * és @ speciális karaktereknek speciális jelentésük van dupla idézõjelek között (lásd a PARAMÉTEREK bekezdést lejjebb).

PARAMÉTEREK

A paraméter egy egység, ami értéket tárol, valami olyasmi, mint a változó egy hagyományos programozási nyelvben. Ez lehet egy  név, egy szám vagy valamelyik speciális karakter, ami a "Speciális Paraméterek" bekezdésben fel van sorolva. A shell céljai miatt a változó egy olyan paraméter, amire névvel  lehet hivatkozni.

Egy paraméter akkor van beállítva, ha értéket rendelünk hozzá. Az üres karaktersorozat is érvényes érték. Ha egyszer beállítottunk egy változót, ezt csak az unset beépített paranccsal (lásd a SHELL BUILTIN COMMANDS bekezdést lejjebb) lehet visszavonni.

Egy változónak a következõ formában lehet értéket adni:

név=[érték]

Ha nincs érték megadva, a változó értéke az üres karaktersorozat lesz. A shell minden értéken sorban végogcsinálja a tilde-kiterjesztést, a paraméterek és változók kifejtését, a parancsok behelyettesítését, az aritmetikai helyettesítést, és eltávolítja az idézõjelezést. Ha a változó -i atribútuma be van állítva (lásd a declare parancsot a SHELL BUILTIN COMMANDS alatt lent), akkor az értéken mindig végrehajtja az aritmetikai kiértékelést, még akkor is, ha nem $[...] formában van megadva. A szavakra bontást nem végzi el, a $@ kivételével ahogy az a Speciális paraméterek alatt le van írva.

Pozícionális paraméterek

A pozícionális paraméterre egy vagy több számjeggyel lehet hivatkozni, kivéve az egyetlen 0 számjeggyet. A pozícionális paraméterek a shell indításkori argumentumait kapják értékül, de a set beépített parancs segítségével megváltozztathatók. A pozícionális paraméterek értéke nem változtatható meg hozzárendelõ utasításokkal. A shell függvényeinek végrehajtása közben a pozícionális paraméterek értéke átmenetileg lecserélõdik. (ld. FUNCTIONS késõbb).

Ha egy pozícionális paraméter egynél több számjegyet tartalmaz, ezeket zárójelbe kell tenni (ld. EXPANSION alább).

Speciális paraméterek

A shell számos paramétert speciálisan kezel. Ezekre a paraméterekre csak hivatkozni lehet, érték hozzárendelése nem megengedett.

*
A pozícionális paramétereket jelöli $1 -tõl. Ha dupla idézõjeleken belül alkalmazzuk, akkor egyetlen szóként viselkedik, amely az egyes paramétereket tertelmazza az IFS változó elsõ karakterével elválasztva. Tehát a ``$*'' pontosan azt jelenti, amit a ``$1c$2c...'' ahol c az elsõ karaktere az IFS változónak. Ha az IFS üres, vagy nincs beállítva, a paramétereket szóköz választja el.

@
A pozícionális paramétereket jelöli $1 -tõl. Ha a kifejezés macskakörmök között jelenik meg, akkor minden paraméter külön önálló szóként jelenik meg. Tehát a `` $@ '' pontosan azt jelenti, mint a ``$1'' ``$2'' ... Ha nincsenek pozícionális paraméterek, a ``$@'' és a $@ nem tartalmaz semmit ill. nincsenek definiálva.

#
A pozícionális paraméterek számát jelenti tizes számrendszerben.

?
A processzazonosítója az utoljára az elõtérben indított pipeline -nak.

-
A shell belsõ kapcsolói, amelyek indításkor vagy a set paranccsal lettek megadva, illetve melyeket a shell állít be.

$
A shell processzazonosítóját tartalmazza. () -ben nem az al-shell, hanem a szülõ PID -jét mutatja.

!
Az utoljára elindított parancs processzazonosítóját jelenti.

0
A shell vagy shell script nevét tartalmazza. A shell indításakor állítódik be. Ha a basht egy parancsfile -lal hívjuk meg, akkor $0 ennek a file-nak a neve lesz. Ha a basht a -c argumentummal hívjuk, akkor a $0 az indított program neve utáni elsõ sztringet fogja jelenteni, ha van ilyen. Egyébként az indított bash , elérési útját fogja tartalmazni.

_
Az elõzõ parancs utolsó argumentumát tárolja a shell helyettesítesek elvégzése után.

A Shell Változói

A shell a követketõ változókat használja:

PPID
A shell szülõprocesszének azonosítója.

PWD
Az aktuális könyvtár neve, a cd parancs hatására változik az értéke.

OLDPWD
Az elõzõ aktuális könyvtár neve, a cd parancs hatására változik az értéke.

REPLY
A read belsõ parancs által beolvasott sor, ha argumentum nélkül hívjuk meg.

UID
A felhasználó azonosítója. A shell indításakor állítódik be.

EUID
A tényleges felhasználó azonosítója. A shell indításakor állítódik be.

BASH
A shell neve, és elérési útja. Az éppen futó bash példány hívható meg vele.

BASH_VERSION
Az éppen futó bash példány verziószáma.

SHLVL
Minden bash indításkor növekszik eggyel.

RANDOM
Minden hivatkozáskor egy véletlen egész szám generálódik. A véletlenszámok sorozata inicializálható, ha értéket adunk a RANDOM . változónak. Ha unset-tel töröljük a RANDOM értékét, akkor elveszti speciális tulajdonságait, még ha késõbb vissza is állítjuk.

SECONDS
Minden hivatkozáskor a shell meghívása óta eltelt idõt adja vissza másodpercben. Ha értéket adunk a I> SECONDS , változónak, akor egy késõbbi hivatkozáskor a változó értéke az értékadástól eltelt idõ és az adott érték összege. Ha unset-tel töröljük a SECONDS értékét, akkor elveszti speciális tulajdonságait, még ha késõbb vissza is állítjuk.

LINENO
Minden hivatkozáskor a shell egy decimális számot ad vissza, ami az aktuális sor sorszámát (1-gyel kezdve) jelöli egy scriptben, vagy eljárásban. Nem scriptben vagy eljárásban használva a kapott érték nem biztos, hogy értelmes. Eljárásban az érték nem a forrásszövegnek a parancsot tartalmazó sora (ez az információ elveszett, amikor az eljárás végrehajtódott.), hanem az eljárásban végrehajtott egyszerû parancsok száma. Ha unset-tel töröljük a LINENO értékét, akkor elveszti speciális tulajdonságait, még ha késõbb vissza is állítjuk.

HISTCMD
A parancs sorszáma a history-ban. Ha unset-tel töröljük a HISTCMD értékét, akkor elveszti speciális tulajdonságait, még ha késõbb vissza is állítjuk.

OPTARG
A getopts belsõ parancs által feldolgozott utolsó opcionális argumentum értéke(lsd. alább A SHELL BELSÔ PARANCSAI ).

OPTIND
A getopts belsõ parancs által feldolgozott utolsó opcionális argumentum sorszáma(lsd. alább SHELL BELSÔ PARANCSAI ).

HOSTTYPE
Egy karakterlánc, mely egyértelmûen jellemzi a gépet, amelyen a bash fut. Az alapértelmezés szerinti érték rendszerfüggõ.

OSTYPE
Egy karakterlánc, ami az operációs rendszert jellemzi, amelyen a bash fut. Az alapértelmezés szerinti érték rendszerfüggõ.

A következõ változókat a shell használja. Néhány esetben a bash egy alap értéket ad egy változóknak; ezeket az eseteket részletezzük alább.

IFS
The Internal Field Separator that is used for word splitting after expansion and to split lines into words with the read builtin command. The default value is ``<space><tab><newline>''.

PATH
The search path for commands. It is a colon-separated list of directories in which the shell looks for commands (see COMMAND EXECUTION below). The default path is system-dependent, and is set by the administrator who installs bash . A common value is ``/usr/gnu/bin:/usr/local/bin:/usr/ucb:/bin:/usr/bin:.''.

HOME
The home directory of the current user; the default argument for the cd builtin command.

CDPATH
The search path for the cd command. This is a colon-separated list of directories in which the shell looks for destination directories specified by the cd command. A sample value is ``.:~:/usr''.

ENV
If this parameter is set when bash is executing a shell script, its value is interpreted as a filename containing commands to initialize the shell, as in .bashrc . The value of ENV is subjected to parameter expansion, command substitution, and arithmetic expansion before being interpreted as a pathname. PATH is not used to search for the resultant pathname.

MAIL
If this parameter is set to a filename and the MAILPATH variable is not set, bash informs the user of the arrival of mail in the specified file.

MAILCHECK
Specifies how often (in seconds) bash checks for mail. The default is 60 seconds. When it is time to check for mail, the shell does so before prompting. If this variable is unset, the shell disables mail checking.

MAILPATH
A colon-separated list of pathnames to be checked for mail. The message to be printed may be specified by separating the pathname from the message with a `?'. $_ stands for the name of the current mailfile. Example:

MAILPATH='/usr/spool/mail/bfox?"You have mail":~/shell-mail?"$_ has mail!"'

Bash supplies a default value for this variable, but the location of the user mail files that it uses is system dependent (e.g., /usr/spool/mail/$USER).

MAIL_WARNING
If set, and a file that bash is checking for mail has been accessed since the last time it was checked, the message ``The mail in mailfile has been read'' is printed.

PS1
The value of this parameter is expanded (see PROMPTING below) and used as the primary prompt string. The default value is ``bash\$ ''.

PS2
The value of this parameter is expanded and used as the secondary prompt string. The default is ``> ''.

PS3
The value of this parameter is used as the prompt for the select command (see SHELL GRAMMAR above).

PS4
The value of this parameter is expanded and the value is printed before each command bash displays during an execution trace. The first character of PS4 is replicated multiple times, as necessary, to indicate multiple levels of indirection. The default is ``+ ''.

HISTSIZE
The number of commands to remember in the command history (see HISTORY below). The default value is 500.

HISTFILE
The name of the file in which command history is saved. (See HISTORY below.) The default value is ~/.bash_history. If unset, the command history is not saved when an interactive shell exits.

HISTFILESIZE
The maximum number of lines contained in the history file. When this variable is assigned a value, the history file is truncated, if necessary, to contain no more than that number of lines. The default value is 500.

OPTERR
If set to the value 1, bash displays error messages generated by the getopts builtin command (see SHELL BUILTIN COMMANDS below). OPTERR is initialized to 1 each time the shell is invoked or a shell script is executed.

PROMPT_COMMAND
If set, the value is executed as a command prior to issuing each primary prompt.

IGNOREEOF
Controls the action of the shell on receipt of an EOF character as the sole input. If set, the value is the number of consecutive EOF characters typed as the first characters on an input line before bash exits. If the variable exists but does not have a numeric value, or has no value, the default value is 10. If it does not exist, EOF signifies the end of input to the shell. This is only in effect for interactive shells.

TMOUT
If set to a value greater than zero, the value is interpreted as the number of seconds to wait for input after issuing the primary prompt. Bash terminates after waiting for that number of seconds if input does not arrive.

FCEDIT
The default editor for the fc builtin command.

FIGNORE
A colon-separated list of suffixes to ignore when performing filename completion (see READLINE below). A filename whose suffix matches one of the entries in FIGNORE is excluded from the list of matched filenames. A sample value is ``.o:~''.

INPUTRC
The filename for the readline startup file, overriding the default of ~/.inputrc (see READLINE below).

notify
If set, bash reports terminated background jobs immediately, rather than waiting until before printing the next primary prompt (see also the -b option to the set builtin command).

history_control

HISTCONTROL
If set to a value of ignorespace , lines which begin with a space character are not entered on the history list. If set to a value of ignoredups , lines matching the last history line are not entered. A value of ignoreboth combines the two options. If unset, or if set to any other value than those above, all lines read by the parser are saved on the history list.

command_oriented_history
If set, bash attempts to save all lines of a multiple-line command in the same history entry. This allows easy re-editing of multi-line commands.

glob_dot_filenames
If set, bash includes filenames beginning with a `.' in the results of pathname expansion.

allow_null_glob_expansion
If set, bash allows pathname patterns which match no files (see Pathname Expansion below) to expand to a null string, rather than themselves.

histchars
The two or three characters which control history expansion and tokenization (see HISTORY EXPANSION below). The first character is the "history expansion character" , that is, the character which signals the start of a history expansion, normally `!'. The second character is the "quick substitution" character, which is used as shorthand for re-running the previous command entered, substituting one string for another in the command. The default is `^'. The optional third character is the character which signifies that the remainder of the line is a comment, when found as the first character of a word, normally `#'. The history comment character causes history substitution to be skipped for the remaining words on the line. It does not necessarily cause the shell parser to treat the rest of the line as a comment.

nolinks
If set, the shell does not follow symbolic links when executing commands that change the current working directory. It uses the physical directory structure instead. By default, bash follows the logical chain of directories when performing commands which change the current directory, such as cd . See also the description of the -P option to the set builtin ( SHELL BUILTIN COMMANDS below).

hostname_completion_file

HOSTFILE
Contains the name of a file in the same format as /etc/hosts that should be read when the shell needs to complete a hostname. The file may be changed interactively; the next time hostname completion is attempted bash adds the contents of the new file to the already existing database.

noclobber
If set, bash does not overwrite an existing file with the > , >& , and <> redirection operators. This variable may be overridden when creating output files by using the redirection operator >| instead of > (see also the -C option to the set builtin command).

auto_resume
This variable controls how the shell interacts with the user and job control. If this variable is set, single word simple commands without redirections are treated as candidates for resumption of an existing stopped job. There is no ambiguity allowed; if there is more than one job beginning with the string typed, the job most recently accessed is selected. The name of a stopped job, in this context, is the command line used to start it. If set to the value exact , the string supplied must match the name of a stopped job exactly; if set to substring , the string supplied needs to match a substring of the name of a stopped job. The substring value provides functionality analogous to the %? job id (see JOB CONTROL below). If set to any other value, the supplied string must be a prefix of a stopped job's name; this provides functionality analogous to the % job id.

no_exit_on_failed_exec
If this variable exists, a non-interactive shell will not exit if it cannot execute the file specified in the exec builtin command. An interactive shell does not exit if exec fails.

cdable_vars
If this is set, an argument to the cd builtin command that is not a directory is assumed to be the name of a variable whose value is the directory to change to.

EXPANSION

Expansion is performed on the command line after it has been split into words. There are seven kinds of expansion performed: "brace expansion" , "tilde expansion" , "parameter and variable expansion" , "command substitution" , "arithmetic expansion" , "word splitting" , and "pathname expansion" .

The order of expansions is: brace expansion, tilde expansion, parameter, variable, command, and arithmetic substitution (done in a left-to-right fashion), word splitting, and pathname expansion.

On systems that can support it, there is an additional expansion available: process substitution.

Only brace expansion, word splitting, and pathname expansion can change the number of words of the expansion; other expansions expand a single word to a single word. The single exception to this is the expansion of ``$@'' as explained above (see PARAMETERS ).

Brace Expansion

"Brace expansion" is a mechanism by which arbitrary strings may be generated. This mechanism is similar to pathname expansion, but the filenames generated need not exist. Patterns to be brace expanded take the form of an optional preamble , followed by a series of comma-separated strings between a pair of braces, followed by an optional postamble . The preamble is prepended to each string contained within the braces, and the postamble is then appended to each resulting string, expanding left to right.

Brace expansions may be nested. The results of each expanded string are not sorted; left to right order is preserved. For example, a{d,c,b}e expands into `ade ace abe'.

Brace expansion is performed before any other expansions, and any characters special to other expansions are preserved in the result. It is strictly textual. Bash does not apply any syntactic interpretation to the context of the expansion or the text between the braces.

A correctly-formed brace expansion must contain unquoted opening and closing braces, and at least one unquoted comma. Any incorrectly formed brace expansion is left unchanged.

This construct is typically used as shorthand when the common prefix of the strings to be generated is longer than in the above example:

mkdir /usr/local/src/bash/{old,new,dist,bugs}

or
chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}}

Brace expansion introduces a slight incompatibility with traditional versions of sh , the Bourne shell. sh does not treat opening or closing braces specially when they appear as part of a word, and preserves them in the output. Bash removes braces from words as a consequence of brace expansion. For example, a word entered to sh as file{1,2} appears identically in the output. The same word is output as file1 file2 after expansion by bash . If strict compatibility with sh is desired, start bash with the -nobraceexpansion flag (see OPTIONS above) or disable brace expansion with the +o braceexpand option to the set command (see SHELL BUILTIN COMMANDS below).

Tilde Expansion

If a word begins with a tilde character (`~'), all of the characters preceding the first slash (or all characters, if there is no slash) are treated as a possible login name. If this login name is the null string, the tilde is replaced with the value of the parameter HOME . If HOME is unset, the home directory of the user executing the shell is substituted instead.

If a `+' follows the tilde, the value of PWD replaces the tilde and `+'. If a `-' follows, the value of OLDPWD is substituted. If the value following the tilde is a valid login name, the tilde and login name are replaced with the home directory associated with that name. If the name is invalid, or the tilde expansion fails, the word is unchanged.

Each variable assignment is checked for unquoted instances of tildes following a : or = . In these cases, tilde substitution is also performed. Consequently, one may use pathnames with tildes in assignments to PATH , MAILPATH , and CDPATH , and the shell assigns the expanded value.

Parameter Expansion

The `$' character introduces parameter expansion, command substitution, or arithmetic expansion. The parameter name or symbol to be expanded may be enclosed in braces, which are optional but serve to protect the variable to be expanded from characters immediately following it which could be interpreted as part of the name.

${parameter}
The value of parameter is substituted. The braces are required when parameter is a positional parameter with more than one digit, or when parameter is followed by a character which is not to be interpreted as part of its name.

In each of the cases below, word is subject to tilde expansion, parameter expansion, command substitution, and arithmetic expansion. Bash tests for a parameter that is unset or null; omitting the colon results in a test only for a parameter that is unset.

${paraméter:-szó}
Alap Értékek Használata. Ha paraméter nincs beéllítva, vagy értéke null, a szó kifejezés helyettesítõdik be. Eltérõ ese tben a paraméter értéke lesz behelyettesítve.

${paraméter:=szó}
Alap Értékek Hozzárendelése. Ha paraméter nincs beállítva, vagy értéke null, a paraméter értéke szó lesz. Ezután a paraméter értéke behlyettesítõdik. Állapotjelzõ és speciális paraméterek nem kaphatnak ezen módon értéket.

${paraméter:?szó}
 Hibaüzenet, ha Null vagy ha Nincs Beállítva. Ha paraméter null, vagy nincs beállítva , a szó (vagy egy üzenet arra az esetre, ha nincs szó) íródik ki a standard error-ra, és a shell, ha nem inaktív, kilép. Eltérõ esetben a paraméter értéke lesz behelyettesítve.

${paraméter:+szó}
 Más Érték Használata. Ha paraméter null vagy nincs beállítva, nem helyettesítõdik be semmi, eltérõ esetben a szó kifejezés lesz behelyettesítve.

${#paraméter}
 A paraméter értékének hossza karakterben lesz behelyettesítve. Ha paraméter * vagy @ , a * hossza lesz behelyettesítve dupla idézõjelek között.

${paraméter#szó}

${paraméter##szó}
 A szó kifejezést az útvonalakhoz hasonlóan mintaszerûen kell megadni. Ha a minta megegyezik a paraméter értékének elejével, a behelyettesített érték a paraméter értéke lesz a legrövidebb megegyezõ rész törlésével ("#" eset) vagy a leghosszabb megegyezõ rész törlésével ("##" eset).

${paraméter%szó}

${paraméter%%szó}
 A szó kifejezést az útvonalakhoz hasonlóan mintaszerûen kell megadni. Ha a minta megyezik a paraméter értékének egy egybefüggõ részével, a behelyettesített érték a paraméter értéke lesz a legrövidebb megegyezõ rész törlésével ("%" eset) vagy a leghosszabb megegyezõ rész törlésével ("%%" eset).

Parancs Helyettesítés

A parancs helyettesítés lehetõvé teszi, hogy a parancs nevét helyettesítsük a parancs kimenetével. Két formája van:
$(parancs)
vagy
`parancs`
A Bash úgy hajtja végre a behelyettesítést, hogy lefuttatja a parancs-ot és a neve helyére beírja a parancs standard kimenetére érkezõ üzenetét, közben az elsõ sort követõ sorokat kitörli.

A régi stílusú szimpla idézõjeles forma esetén a fordított perjel megtartja speciális jelentését kivéve, ha $,`, vagy \ követi. A $(parancs) forma esetén minden karakter a zárójelen belül alkotja a végrehajtandó parancsot, egyik sincs speciálisan kezelve.

A parancs helyettesítéseket egymásba lehet ágyazni. Ha a régi stílusú formát használjuk, a belsõ idézõjelek elé fordított perjelet kell rakni.

Ha a helyettesítés idézõjelek között van, szódarabolás és útvonalhelyettesítés nem hajtódik végre az eredményen.

Aritmetikai Helyettesítés

Az artimetikai helyettesítés lehetõvé teszi egy matematikai kifejezés kiértékelését illetve az eredmény behelyettesítését. Az aritmetikai helyettesítésnek két formája van:
$[kifejezés]

$((kifejezés))

A kifejezést a bash úgy kezeli, mintha idézõjelek között lenne, de a zárójelek közötti idézõjelet nem kezeli speciálisan. A kifejezésben minden elemre érvényes a paraméter helyettesítés, parancs helyettesítés, és az idézõjel eltávolítás. Az aritmetikai helyettesítéseket egymásba lehet ágyazni.

A kiértékelés az "ARITHMETIC EVALUATION" címszó alatt található szabályok szerint történik. Ha a kifejezés szabálytalan, a bash hibaüzenetet ír ki, és nem történik behelyettesítés.

Processz helyettesítés

A processz helyettesítés olyan rendszereken mûködik, ami támogatja a névvel ellátott pipe-okat. (FIFO-k) vagy a /dev/fd eljárást nyitott fájlok elnevezésére. Formája: <(list) vagy >(list) . A list processz úgy fut, hogy bemenete vagy kimenete egy FIFO-hoz vagy egy /dev/fd-beli fájlhoz van kapcsolva. Ezen fájl neve a kiértékelés eredménye, és argumentumként adódik át a jelenlegi parancsnak. Ha a >(lista) formát használjuk, a fájlba írt adat lista bemenetére kerül Ha a <(lista) formát használjuk, az argumentumként átadott fájl tartalma kerül lista kimenetére.

Az ezt támogató rendszereken a processz helyettesítés egyidejûleg hajtódik végre az alábbiakkal: "paraméter és változó kiértékelés" , "parancs helyettesítés" , és aritmetikai helyettesítés".

Szavakra bontás

A shell "szavakra bontás" céljából átvizsgálja a paraméter kifejtés, parancs helyettesítés és az aritmetikai helyettesítés nem idézõjelben szereplõ eredményeit.

A shell az IFS minden egyes karakterét elválasztó jelnek tekinti, amelyek alapján a másik kifejezést szavakra bontja. Ha az IFS tartalma pontosan <space><tab><newline> , az alapbeállítás, akkor az IFS karaktereinek bármely sorozata is szóelválasztó. Ha IFS értéke eltér az alapbeállítástól, akkor a space és tab "szóköz" karakterek szóeleji és szóvégi sorozata nem fog a szóhoz tartozni, ha azokat az IFS tartalmazza (egy IFS szóköz karakter). Az IFS bármely (egyetlen) karaktere, ami nem IFS szóköz, bármely szomszédos IFS szóközzel együtt egy mezõt határol el. Az IFS szóközšk sorozata szintén határolóként viselkedik. Ha IFS értéke üres, a szavakra bontás nem történik meg. IFS értéke nem törölhetõ.

A konkrét üres argumentumok ("" vagy '') megõrzõdnek. A közvetett üres argumentumok, amelyek üres paraméterek kiértékelésekor adódnak, eltávolítódnak.

Megjegyezzük, hogy ha nem történik kiértékelés, akkor szavakra bontás sincsen.

Útvonal Helyettesítés

Szavakra bontás után - hacsak nincs megadva a -f kapcsoló - a bash minden egyes szóban az alábbi jeleket keresi: * , ? , és [ . Ha bármelyikük megjelenik, akkor a szót mintának tekinti, és a mintának megfelelõ útvonalak ábécé szerint rendezett listájára cseréli ki. Megfelelõ útvonal hiányában, és ha az allow_null_glob_expansion shell változó nincs beállítva, a szó változatlan marad. Ha a változó be van állítva, de nincs megfelelõ útvonal, akkor a szó eltávolítódik. Ha minta használatával hozunk létre útvonalat, a ``.'' karakternek egy név kezdetekor vagy közvetlenül egy perjel után pontosan kell egyeznie, hacsak nincs bekapcsolva a glob_dot_filenames shell változó. A perjelnek mindig pontosan egyeznie kell. Más esetekben a ``.'' karaktert nem kezeli különlegesen.

A minta különleges karaktereinek a kšvetkezõ a jelentésük:

*
Minden sztringgel megegyezik, beleértve az üres sztringet.

?
Pontosan egy karakterre illeszkedik.

[...]
A zárójelen belüli karakterek közül bármelyik egy. A kötõjellel elválasztott karakterek egy tartományt határoznak meg; bármely ábécésorrendben közéjük esõ karakter illeszkedni fog. Ha az elsõ karakter a [ után egy ! vagy egy ^, akkor bármely nem közéjük esõ karakter fog illeszkedni. A - vagy ] karakterek is használhatók mintaként, ha a karakterhalmaz elsõ vagy utolsó elemét képezik.

Quote Removal

After the preceding expansions, all unquoted occurrences of the characters \ , ` , and " are removed.

REDIRECTION

Before a command is executed, its input and output may be redirected using a special notation interpreted by the shell. Redirection may also be used to open and close files for the current shell execution environment. The following redirection operators may precede or appear anywhere within a simple command or may follow a command . Redirections are processed in the order they appear, from left to right.

In the following descriptions, if the file descriptor number is omitted, and the first character of the redirection operator is < , the redirection refers to the standard input (file descriptor 0). If the first character of the redirection operator is > , the redirection refers to the standard output (file descriptor 1).

The word that follows the redirection operator in the following descriptions is subjected to brace expansion, tilde expansion, parameter expansion, command substitution, arithmetic expansion, quote removal, and pathname expansion. If it expands to more than one word, bash reports an error.

Note that the order of redirections is significant. For example, the command

ls > dirlist 2>&1

directs both standard output and standard error to the file dirlist , while the command

ls 2>&1 > dirlist

directs only the standard output to file dirlist , because the standard error was duplicated as standard output before the standard output was redirected to dirlist .

Redirecting Input

Redirection of input causes the file whose name results from the expansion of word to be opened for reading on file descriptor n , or the standard input (file descriptor 0) if n is not specified.

The general format for redirecting input is:

[n]<word

Redirecting Output

Redirection of output causes the file whose name results from the expansion of word to be opened for writing on file descriptor n , or the standard output (file descriptor 1) if n is not specified. If the file does not exist it is created; if it does exist it is truncated to zero size.

The general format for redirecting output is:

[n]>word

If the redirection operator is >| , then the value of the -C option to the set builtin command is not tested, and file creation is attempted. (See also the description of noclobber under "Shell Variables" above.)

Appending Redirected Output

Redirection of output in this fashion causes the file whose name results from the expansion of word to be opened for appending on file descriptor n , or the standard output (file descriptor 1) if n is not specified. If the file does not exist it is created.

The general format for appending output is:

[n]>>word

Redirecting Standard Output and Standard Error

Bash allows both the standard output (file descriptor 1) and the standard error output (file descriptor 2) to be redirected to the file whose name is the expansion of word with this construct.

There are two formats for redirecting standard output and standard error:

&>word

and
>&word

Of the two forms, the first is preferred. This is semantically equivalent to

>word 2>&1

Here Documents

This type of redirection instructs the shell to read input from the current source until a line containing only word (with no trailing blanks) is seen. All of the lines read up to that point are then used as the standard input for a command.

The format of here-documents is as follows:

<<[-]word
        here-document
delimiter

No parameter expansion, command substitution, pathname expansion, or arithmetic expansion is performed on word . If any characters in word are quoted, the delimiter is the result of quote removal on word , and the lines in the here-document are not expanded. Otherwise, all lines of the here-document are subjected to parameter expansion, command substitution, and arithmetic expansion. In the latter case, the pair \<newline> is ignored, and \ must be used to quote the characters \ , $ , and ` .

If the redirection operator is <<- , then all leading tab characters are stripped from input lines and the line containing delimiter . This allows here-documents within shell scripts to be indented in a natural fashion.

Duplicating File Descriptors

The redirection operator

[n]<&word

is used to duplicate input file descriptors. If word expands to one or more digits, the file descriptor denoted by n is made to be a copy of that file descriptor. If word evaluates to - , file descriptor n is closed. If n is not specified, the standard input (file descriptor 0) is used.

The operator

[n]>&word

is used similarly to duplicate output file descriptors. If n is not specified, the standard output (file descriptor 1) is used. As a special case, if n is omitted, and word does not expand to one or more digits, the standard output and standard error are redirected as described previously.

Opening File Descriptors for Reading and Writing

The redirection operator

[n]<>word

causes the file whose name is the expansion of word to be opened for both reading and writing on file descriptor n , or as the standard input and standard output if n is not specified. If the file does not exist, it is created.

FUNCTIONS

A shell function, defined as described above under "SHELL GRAMMAR" , stores a series of commands for later execution. Functions are executed in the context of the current shell; no new process is created to interpret them (contrast this with the execution of a shell script). When a function is executed, the arguments to the function become the positional parameters during its execution. The special parameter # is updated to reflect the change. Positional parameter 0 is unchanged.

Variables local to the function may be declared with the local builtin command. Ordinarily, variables and their values are shared between the function and its caller.

If the builtin command return is executed in a function, the function completes and execution resumes with the next command after the function call. When a function completes, the values of the positional parameters and the special parameter # are restored to the values they had prior to function execution.

Function names and definitions may be listed with the -f option to the declare or typeset builtin commands. Functions may be exported so that subshells automatically have them defined with the -f option to the export builtin.

Functions may be recursive. No limit is imposed on the number of recursive calls.

AZ ALIAS MECHANIZMUS

A shell által nyújtott aliasok beállítása illetve törlése a beépített alias illetve unalias parancsok segítségével történhet(lásd feljebb a SHELL BUILTIN COMMANDS részt). Minden parancs elsõ szava, ha nem idézõjelek között van, szolgál arra, hogy a shell leellenõrizze : szerepel-e az alias listában. Ha igen, akkor behelyettesíti az illetõ alias definícióját a listából. Az alias neve és a behelyettesített szöveg bármilyen érvényes shell bementet tartalmazhat, beleértve az alább felsorolt metakaraktereket is, azzal a kivétellel , hogy az alias nevében nem szerepelhet az = jel. A behelyettesített szöveg elsõ szava az aliasok ellenõrzésére szolgál, és ha a következõ menetben egy már kifejtett alias kerül sorra , azt a shell másodszorra már nem fejti ki . Ez azt jelenti , hogy például az ls választható aliasnak az "ls -F"-hez, és a bash a behelyettesített szöveget nem rekurzívan fejti ki . Ha az alias értékének utolsó karaktere üres(blank), akkor a bash ellenõrzi az aliast követõ utolsó parancsszó kiterjesztését.

Aliasok létrehozása és a lista bõvítése az alias, aliasok törlése az unalias parancsal történik.

Az argumentumok használatára nincs semmiféle eljárás, mint a csh-ben. Ha szükség van argumentumokra, akkor egy shell függvényt kell alkalmazni.

Nem kerülnek az aliasok kifejtésre, amikor a shell nem párbeszédes módban üzemel.

Az aliasok definíciójára és használatára vonatkozó szabályok egy kissé megzavarók. A bash mindig legalább egy teljes sornyi bemenetet olvas, mielõtt bármely parancsot végrehajtana a soron. Az aliasok kifejtése a parancsok olvasásakor és nem a végrehajtásakor történik. Éppen ezért az alias definíciója ugyanazon a soron jelenik meg, mivel más parancs nem csinál semmit, míg a bemenet következõ sorát nem olvassuk. Ez azt jelenti, hogy az alias definícióját követõ parancsokat az új alias nem befolyásolja. Ez a kérdés a függvények végrehajtásakor is felmerül. Az aliasok kifejtése a függvények olvasásakor, és nem a végrehajtásukkor történik, mert a függvény definíció önmagában is összetett parancs. Következésképpen, a függvényben definiált aliasok annak végrehajtásáig nem elérhetõk. Hogy elkerüljük a hibát, az alias definícióját mindig külön sorba írjuk, és ne alkalmazzuk az alias parancsot összetett parancsokban.

Majdnem minden esetben az aliasok shell függvényekkel helyettesíthetõk.

JOB KEZELÉS

jobkezelés azt jelenti, hogy a shell képes a folyamatok végrehajtását megállítani (suspend), és késõbbi idõpontban folytatni(resume) azt. A felhasználó olyan interaktív interface-n keresztül alkalmazhatja ezt a lehetõséget, amely rendszer terminál meghajtóval és bash-sel van ellátva.

A shell minden pipeline-hoz egy jobot kapcsol. Az éppen futó job-ok listája egy táblazatban szerepel, amelyet a jobs paranccsal tekinthetünk meg. Amikor a bash a háttérben indít el egy job-ot, akkor a következõhöz hasonló sort nyomtatja ki:

[1] 25647

ahol az 1 szám azt jelzi, hogy az elsõ job fut, a második pedig azt, hogy a pipeline-ban az utolsó folyamat azonosítója, amely ehhez a job-hoz tartozik : 25647. Az egy pipelineban szereplõ összes folyamat ugyanahhoz a job-hoz tartozik. A bash job absztrakciót alkalmaz a job-kezeléshez.

A job kezeléshez szükséges felhasználói interface megvalósításának megkönnyítésére az aktuális terminál processz csoportazonosítójáról táblázatot kezel. Ennek a processz csoportnak a tagjai (azok a folyamatok, amelyeknek csoportazonosítója megegyezik az aktuális terminál folyamatok csoportazonosítójával) billentyûzet generálta jeleket, mint a SIGINT kapnak. Ezeket a folyamatokat elõtérben futó folyamatoknak nevezzük. A háttérfolyamatok azok, amelyeknek a csoportazonosítója a terminálétól különbözik. Ezek a folyamatok védettek a billentyûzet generálta jelekkel szemben. Csak az elõtérben futó folyamatok olvashatnak a terminálról, illetve írhatnak oda. Azok a háttérfolyamatok, amelyek megkísérlik a képernyõrõl való olvasást (illetve az arra való írást) a terminál vezérlõtõl SIGTTIN (SIGTTOU) jelzést kapnak, amely felfüggeszti a folyamatokat.

Ha az operációs rendszer, amelyen a bash fut, támogatja a job kezelést, akkor a bash engedélyezi annak használatát. A felfüggesztõ karakter begépelése a folyamat futása közben (tipikusan ^Z, Control-Z) a folyamat megállását és a felhasznalónak a bash-hoz való visszatérését eredményezi. A késleltetett felfüggesztõ karakter (tipikusan ^Y, Control-Y) a folyamat megállását okozza, miközben a bementét a terminálról akarja olvasni, és ellenõrzi, a bash-hoz való visszatérését. Parancsokkal befolyásolhatjuk a job állapotát, a bg parancs hatására a háttérben fog futni, az fg hatására az elõtérben, a kill pedig végleg leállítja a job-ot. A ^Z hatása azonnal érvényesül, és hatására a várakozó kimenet és az elõre begépelt adatok elvesznek.

Számtalan módon hivatkozhatunk a jobokra a shellben. Az aktuális job-ra való hivatkozás a % jellel történik, az n. jobra %n-nel. Job-ra úgy is hivatkozhatunk, hogy annak a névnek az elõtagját amely elindítja, vagy egy a parancs soraban megjelenõ szöveg részletet használunk. Pl. %ce egy leállított ce job-ra vonatkozik. Ha az elõtag több mint egy job-hoz kapcsolódhat, a bash hibát jelez. Másfelõl %?ce használata bármilyen olyan job-ot magába foglal, amely parancssorában a ce szöveget tartalmazza. Ha a szövegrészlet több mint egy job-ra vonatkozhat, akkor a bash hibát jelez. A %% és a %+ szimbólumok az "aktuális job"-ot jelölik, amely az elõtérben utólsóként felfüggesztett job volt. Az "elõzõ job"-ra a %- szimbólummal hivatkozhatunk. A job-hoz tartozó kimenetben (vagyis a jobs parancs kimenetében) az aktuális job-ra való hivatkozás a +, az elõzõ job-ot a - flag-gel jelöljük.

A job-ok elõterbe hozása egyszerûen történhet a job megnevezésével is: %1 ugyanaz, mint az ``fg %1'', amely az elsõ job-ot a háttérbõl az elõtérbe hozza. Hasonlóképpen a ``%1 &'' , amely visszateszi az 1 jobot a háttérbe, ekvivalens a ``bg %1'' paranccsal.

A shell azonnal értesül a job állapotának megváltozásáról. Rendes körülmények között a bash a prompt kiírásáig várakozik a job állapotában történt változások jelentésével, azért, hogy ne szakítson meg bármilyen más kimenetet. Ha a set beépített parancs -b opciója be van állítva, a bash azonnal jelenti a job állapotában történt változásokat. (Lásd feljebb a "Shell variables" címszó alatt a notify változókról szóló leírást.)

Ha job-ok leállása elõtt kísérelnénk meg elhagyni a bash-t, akkor hibaüzenetet kapunk. Azután használhatjuk a jobs parancsot a job-ok állapotának kiderítésére. Ha így jár el az ember, vagy ismét megpróbál azonnal kilépni, már nem kap hibaüzenetet,a leállított job-ok befejezõdnek.

SIGNALS

When bash is interactive, it ignores SIGTERM (so that kill 0 does not kill an interactive shell), and SIGINT is caught and handled (so that the wait builtin is interruptible). In all cases, bash ignores SIGQUIT . If job control is in effect, bash ignores SIGTTIN , SIGTTOU , and SIGTSTP .

Synchronous jobs started by bash have signals set to the values inherited by the shell from its parent. When job control is not in effect, background jobs (jobs started with & ) ignore SIGINT and SIGQUIT . Commands run as a result of command substitution ignore the keyboard-generated job control signals SIGTTIN , SIGTTOU , and SIGTSTP .

COMMAND EXECUTION

After a command has been split into words, if it results in a simple command and an optional list of arguments, the following actions are taken.

If the command name contains no slashes, the shell attempts to locate it. If there exists a shell function by that name, that function is invoked as described above in FUNCTIONS . If the name does not match a function, the shell searches for it in the list of shell builtins. If a match is found, that builtin is invoked.

If the name is neither a shell function nor a builtin, and contains no slashes, bash searches each element of the PATH for a directory containing an executable file by that name. If the search is unsuccessful, the shell prints an error message and returns a nonzero exit status.

If the search is successful, or if the command name contains one or more slashes, the shell executes the named program. Argument 0 is set to the name given, and the remaining arguments to the command are set to the arguments given, if any.

If this execution fails because the file is not in executable format, and the file is not a directory, it is assumed to be a shell script, a file containing shell commands. A subshell is spawned to execute it. This subshell reinitializes itself, so that the effect is as if a new shell had been invoked to handle the script, with the exception that the locations of commands remembered by the parent (see hash below under SHELL BUILTIN COMMANDS) are retained by the child.

If the program is a file beginning with #! , the remainder of the first line specifies an interpreter for the program. The shell executes the specified interpreter on operating systems that do not handle this executable format themselves. The arguments to the interpreter consist of a single optional argument following the interpreter name on the first line of the program, followed by the name of the program, followed by the command arguments, if any.

ENVIRONMENT

When a program is invoked it is given an array of strings called the environment . This is a list of name-value pairs, of the form "name=value" .

The shell allows you to manipulate the environment in several ways. On invocation, the shell scans its own environment and creates a parameter for each name found, automatically marking it for export to child processes. Executed commands inherit the environment. The export and declare -x commands allow parameters and functions to be added to and deleted from the environment. If the value of a parameter in the environment is modified, the new value becomes part of the environment, replacing the old. The environment inherited by any executed command consists of the shell's initial environment, whose values may be modified in the shell, less any pairs removed by the unset command, plus any additions via the export and declare -x commands.

The environment for any simple command or function may be augmented temporarily by prefixing it with parameter assignments, as described above in PARAMETERS . These assignment statements affect only the environment seen by that command.

If the -k flag is set (see the set builtin command below), then all parameter assignments are placed in the environment for a command, not just those that precede the command name.

When bash invokes an external command, the variable _ is set to the full path name of the command and passed to that command in its environment.

EXIT STATUS

For the purposes of the shell, a command which exits with a zero exit status has succeeded. An exit status of zero indicates success. A non-zero exit status indicates failure. When a command terminates on a fatal signal, bash uses the value of 128+signal as the exit status.

If a command is not found, the child process created to execute it returns a status of 127. If a command is found but is not executable, the return status is 126.

Bash itself returns the exit status of the last command executed, unless a syntax error occurs, in which case it exits with a non-zero value. See also the exit builtin command below.

PROMPTING

When executing interactively, bash displays the primary prompt PS1 when it is ready to read a command, and the secondary prompt PS2 when it needs more input to complete a command. Bash allows these prompt strings to be customized by inserting a number of backslash-escaped special characters that are decoded as follows:

\t
the current time in HH:MM:SS format

\d
the date in "Weekday Month Date" format (e.g., "Tue May 26")

\n
newline

\s
the name of the shell, the basename of $0 (the portion following the final slash)

\w
the current working directory

\W
the basename of the current working directory

\u
the username of the current user

\h
the hostname

\#
the command number of this command

\!
the history number of this command

\$
if the effective UID is 0, a # , otherwise a $

\nnn
the character corresponding to the octal number nnn

\\
a backslash

\[
begin a sequence of non-printing characters, which could be used to embed a terminal control sequence into the prompt

\]
end a sequence of non-printing characters

The command number and the history number are usually different: the history number of a command is its position in the history list, which may include commands restored from the history file (see HISTORY below), while the command number is the position in the sequence of commands executed during the current shell session. After the string is decoded, it is expanded via parameter expansion, command substitution, arithmetic expansion, and word splitting.

READLINE

This is the library that handles reading input when using an interactive shell, unless the -nolineediting option is given. By default, the line editing commands are similar to those of emacs. A vi-style line editing interface is also available.

In this section, the emacs-style notation is used to denote keystrokes. Control keys are denoted by C-key, e.g., C-n means Control-N. Similarly, meta keys are denoted by M-key, so M-x means Meta-X. (On keyboards without a meta key, M-x means ESC x, i.e., press the Escape key then the x key. This makes ESC the meta prefix. The combination M-C-x means ESC-Control-x, or press the Escape key then hold the Control key while pressing the x key.)

The default key-bindings may be changed with an ~/.inputrc file. The value of the shell variable INPUTRC , if set, is used instead of ~/.inputrc . Other programs that use this library may add their own commands and bindings.

For example, placing

M-Control-u: universal-argument

or
C-Meta-u: universal-argument
into the ~/.inputrc would make M-C-u execute the readline command universal-argument .

The following symbolic character names are recognized: RUBOUT , DEL , ESC , LFD , NEWLINE , RET , RETURN , SPC , SPACE , and TAB . In addition to command names, readline allows keys to be bound to a string that is inserted when the key is pressed (a macro).

Readline is customized by putting commands in an initialization file. The name of this file is taken from the value of the INPUTRC variable. If that variable is unset, the default is ~/.inputrc . When a program which uses the readline library starts up, the init file is read, and the key bindings and variables are set. There are only a few basic constructs allowed in the readline init file. Blank lines are ignored. Lines beginning with a # are comments. Lines beginning with a $ indicate conditional constructs. Other lines denote key bindings and variable settings.

The syntax for controlling key bindings in the ~/.inputrc file is simple. All that is required is the name of the command or the text of a macro and a key sequence to which it should be bound. The name may be specified in one of two ways: as a symbolic key name, possibly with Meta- or Control- prefixes, or as a key sequence. When using the form keyname:function-name or macro, keyname is the name of a key spelled out in English. For example:

Control-u: universal-argument
Meta-Rubout: backward-kill-word
Control-o: ">&output"

In the above example, C-u is bound to the function universal-argument , M-DEL is bound to the function backward-kill-word , and C-o is bound to run the macro expressed on the right hand side (that is, to insert the text >&output into the line).

In the second form, "keyseq":function-name or macro, keyseq differs from keyname above in that strings denoting an entire key sequence may be specified by placing the sequence within double quotes. Some GNU Emacs style key escapes can be used, as in the following example.

"\C-u": universal-argument
"\C-x\C-r": re-read-init-file
"\e[11~": "Function Key 1"

In this example, C-u is again bound to the function universal-argument . "C-x C-r" is bound to the function re-read-init-file , and "ESC [ 1 1 ~" is bound to insert the text "Function Key 1" . The full set of escape sequences is

\C-
control prefix

\M-
meta prefix

\e
an escape character

\\
backslash

\
literal "

\'
literal '

When entering the text of a macro, single or double quotes should be used to indicate a macro definition. Unquoted text is assumed to be a function name. Backslash will quote any character in the macro text, including " and '.

Bash allows the current readline key bindings to be displayed or modified with the bind builtin command. The editing mode may be switched during interactive use by using the -o option to the set builtin command (see SHELL BUILTIN COMMANDS below).

Readline has variables that can be used to further customize its behavior. A variable may be set in the inputrc file with a statement of the form

set variable-name value

Except where noted, readline variables can take the values On or Off . The variables and their default values are:

horizontal-scroll-mode (Off)
When set to On, makes readline use a single line for display, scrolling the input horizontally on a single screen line when it becomes longer than the screen width rather than wrapping to a new line.

editing-mode (emacs)
Controls whether readline begins with a set of key bindings similar to emacs or vi. editing-mode can be set to either emacs or vi .

mark-modified-lines (Off)
Ha bekapcsolt (On) állapotban van, a módosított history sorok csillag karakterrel kezdődnek.(*).

bell-style (audible)
Megmondja, hogy mi történjen, ha a sorolvasó meg akarja szólaltatni a terminálon a csengőt. Ha none állapotban van, a sorolvasó sohsem szólaltatja meg. Ha visible állapotba van kapcsolva, a sorolvasó látható csengőt használ, ha ez elérhető. Abban az esetben, ha audible-ra van állítva, a sorolvasó megpróbálja megszólaltatni a terminál csengőjét.

comment-begin (``#'')
vi módban, a vi-comment parancs végrehajtásakor ez a sztring kerül behelyezésre.

meta-flag (Off)
Bekapcsolt (On) állapotban a sorolvasó megengedi a 8 bites bevitelt (azaz nem fogja levenni a legmagasabb helyértékű bitet a beolvasott karakterről) függetlenül attól, hogy a terminál mit állít arról, hogy mit támogat.

convert-meta (On)
Bekapcsolt (On) állapotban a sorolvasó a 8-bites karaktereket ASCII szekvenciává alakítja, úgy, hogy levágja a 8. bitet és egy escape karaktert helyez be (lényegében az escape-et meta prefix-ként alkalmazza).

output-meta (Off)
Bekapcsolt (On) állapotban a sorolvasó a 8-bites karaktereket közvetlenül fogja megjeleníteni, a meta-prefixes escape szekvencia helyett.

completion-query-items (100)
Ez mondja meg, hogy a felhasználót mikor kérdezzük meg, hogy megnézi-e a lehetséges befejezéseket, amiket a possible-completions parancs generált. Bármilyen nullánál nagyobb vagy egyenlő egész értékre állítható. Ha a lehetséges befejezések száma nagyobb vagy egyenlő ennél a változónál, a felhasználót megkérdezzük, hogy meg akarja-e nézni őket, különben egyszerüen kilistázzuk a terminálra.

keymap (emacs)
Beállítja az aktuális sorolvasó keymap-jét. A választható keymap nevek halmaza az alábbi: emacs, emacs-standard, emacs-meta, emacs-ctlx, vi, vi-move, vi-command, és vi-insert . A vi ugyanaz mint a vi-command; az emacs ugyanaz, mint az emacs-standard. Az alapértelmezett érték az emacs ; az editing-mode értéke szintén befolyásolja az alapértelmezett keymap-et.

show-all-if-ambiguous (Off)
Megváltoztatja a befejezési funkciók alapértelmezett viselkedését. Bekapcsolt ( on ) állapotban a több lehetséges módon befejezhető szavak hatására a befejezések rögtön kilistázódnak a csengő megszólalása helyett.

expand-tilde (Off)
Bekapcsolt (on) állapotban a tilde kiterjesztés a sorolvasó szóbefejezési kisérleténél történik meg.

A sorolvasó a C preprocesszor feltételes fordítási készségéhez hasonlót művel, azzal, hogy megengedi a billentyűparancsokat és változó beállitásokat tesztek alapján. Háromféle behelyettesítő direktíva létezik.

$if
Az $if konstrukció megengedi, hogy billentyűparancsokat osszunk ki a szerkesztő üzemmód, a használt terminál, illetve a sorolvasót használó program függvényében. A teszt szövege a sor végéig terjed ki, nincs szükség elválasztó karakterekre.

mode
A mode= formája az $if direktívának arra használható, hogy megmondja, hogy a sorolvasó emacs avagy vi módban van-e. Ez használható a set keymap paranccsal kombinálva, például, hogy a billentyűparancsokat beállítsuk az emacs-standard és emacs-ctlx keymap-ekben, de csak akkor, ha a sorolvasó emacs módban indul.

term
A term= forma használható terminál-specifikus billentyű parancsok kiosztásához, például, hogy a kulcs szekvenciák kimenetét a termináló funkcióbillentyűihez kössük. Az egyenlőségjel jobb oldalán lévő szavat a terminál teljes nevével és az első - jel előtti terminál név részlettel hasonlítjuk össze. Ily módon például a sun mind a sun, mind a sun-cmd -ra megfelel.

application
Az application konstrukció megengedi az alkalmazás- specifikus beállításokat. Minden a readline-t használó program beállítja az application name változót és az inicializáló file-lal kereshetjük a szóban forgó értéket. Ezt lehet például billentyűparancsok adott program funkcióhoz társításra használni. Például, a következő parancs egy a mostani vagy korábbi szót idéző kulcs szekvenciát hoz létre a Bash-ban:
$if Bash
# A mostani vagy korábbi szót írja ki
"\C-xq": "\eb\"\ef\""
$endif

$endif
Ez a parancs, mint az előző példából látható, egy $if parancsot zár le.

$else
Az ebben az ágban található parancsok, akkor futnak le, ha az $if direktíva tesztje hamisat ad.

A sorolvasó parancsok numerikus argumentumokat kaphatnak, amelyek általában ismétlésszámláló szerepet töltenek be. Azonban néha, az argumentum előjele a fontos. Negatív argumentum adásakor az előre haladó program (pl. kill-line) hátrafelé fog működni. Az ettől a futási tulajdonságtól különböző parancsokat megjelöljük.

Amikor egy parancsra szöveg ölőként hivatkozunk (killing text), a törölt szöveg eltárolásra kerül a későbbi felhasználás esetére (ezt hivják yanking nek). A megölt szöveg egy kill-ring-ben tárolódik. Egymásutáni ölések a szöveget egy egységbe halmozzák be, amit egyszerre lehet visszahozni. Azok a parancsok amelyek nem text ölők megosztják a text darabkákat a kill-ring-ben.

Az alábbiakban kiírjuk a parancsok nevét és az alapértelmezés szerinti billentyűparancsot amelyekhez kötöttek.

Commands for Moving

beginning-of-line (C-a)
Move to the start of the current line.

end-of-line (C-e)
Move to the end of the line.

forward-char (C-f)
Move forward a character.

backward-char (C-b)
Move back a character.

forward-word (M-f)
Move forward to the end of the next word. Words are composed of alphanumeric characters (letters and digits).

backward-word (M-b)
Move back to the start of this, or the previous, word. Words are composed of alphanumeric characters (letters and digits).

clear-screen (C-l)
Clear the screen leaving the current line at the top of the screen. With an argument, refresh the current line without clearing the screen.

redraw-current-line
Refresh the current line. By default, this is unbound.

Commands for Manipulating the History

accept-line (Newline, Return)
Accept the line regardless of where the cursor is. If this line is non-empty, add it to the history list according to the state of the HISTCONTROL variable. If the line is a modified history line, then restore the history line to its original state.

previous-history (C-p)
Fetch the previous command from the history list, moving back in the list.

next-history (C-n)
Fetch the next command from the history list, moving forward in the list.

beginning-of-history (M-<)
Move to the first line in the history.

end-of-history (M->)
Move to the end of the input history, i.e., the line currently being entered.

reverse-search-history (C-r)
Search backward starting at the current line and moving `up' through the history as necessary. This is an incremental search.

forward-search-history (C-s)
Search forward starting at the current line and moving `down' through the history as necessary. This is an incremental search.

non-incremental-reverse-search-history (M-p)
Search backward through the history starting at the current line using a non-incremental search for a string supplied by the user.

non-incremental-forward-search-history (M-n)
Search forward through the history using a non-incremental search for a string supplied by the user.

history-search-forward
Search forward through the history for the string of characters between the start of the current line and the current point. This is a non-incremental search. By default, this command is unbound.

history-search-backward
Search backward through the history for the string of characters between the start of the current line and the current point. This is a non-incremental search. By default, this command is unbound.

yank-nth-arg (M-C-y)
Insert the first argument to the previous command (usually the second word on the previous line) at point (the current cursor position). With an argument n , insert the nth word from the previous command (the words in the previous command begin with word 0). A negative argument inserts the nth word from the end of the previous command.

yank-last-arg (M-., M-_)
Insert the last argument to the previous command (the last word on the previous line). With an argument, behave exactly like yank-nth-arg.

shell-expand-line (M-C-e)
Expand the line the way the shell does when it reads it. This performs alias and history expansion as well as all of the shell word expansions. See HISTORY EXPANSION below for a description of history expansion.

history-expand-line (M-^)
Perform history expansion on the current line. See HISTORY EXPANSION below for a description of history expansion.

insert-last-argument (M-., M-_)
A synonym for yank-last-arg.

operate-and-get-next (C-o)
Accept the current line for execution and fetch the next line relative to the current line from the history for editing. Any argument is ignored.

Commands for Changing Text

delete-char (C-d)
Delete the character under the cursor. If point is at the beginning of the line, there are no characters in the line, and the last character typed was not C-d , then return EOF .

backward-delete-char (Rubout)
Delete the character behind the cursor. When given a numeric argument, save the deleted text on the kill-ring.

quoted-insert (C-q, C-v)
Add the next character that you type to the line verbatim. This is how to insert characters like C-q, for example.

tab-insert (C-v TAB)
Insert a tab character.

self-insert (a, b, A, 1, !, ...)
Insert the character typed.

transpose-chars (C-t)
Drag the character before point forward over the character at point. Point moves forward as well. If point is at the end of the line, then transpose the two characters before point. Negative arguments don't work.

transpose-words (M-t)
Drag the word behind the cursor past the word in front of the cursor moving the cursor over that word as well.

upcase-word (M-u)
Uppercase the current (or following) word. With a negative argument, do the previous word, but do not move point.

downcase-word (M-l)
Lowercase the current (or following) word. With a negative argument, do the previous word, but do not move point.

capitalize-word (M-c)
Capitalize the current (or following) word. With a negative argument, do the previous word, but do not move point.

Killing and Yanking

kill-line (C-k)
Kill the text from the current cursor position to the end of the line.

backward-kill-line (C-x C-Rubout)
Kill backward to the beginning of the line.

unix-line-discard (C-u)
Kill backward from point to the beginning of the line.

kill-whole-line
Kill all characters on the current line, no matter where the cursor is. By default, this is unbound.

kill-word (M-d)
Kill from the cursor to the end of the current word, or if between words, to the end of the next word. Word boundaries are the same as those used by forward-word.

backward-kill-word (M-Rubout)
Kill the word behind the cursor. Word boundaries are the same as those used by backward-word.

unix-word-rubout (C-w)
Kill the word behind the cursor, using white space as a word boundary. The word boundaries are different from backward-kill-word.

delete-horizontal-space
Delete all spaces and tabs around point. By default, this is unbound.

yank (C-y)
Yank the top of the kill ring into the buffer at the cursor.

yank-pop (M-y)
Rotate the kill-ring, and yank the new top. Only works following yank or yank-pop .

Numerikus argumentumok

szám-argumentum (M-0, M-1, ..., M--)
Add ezt a számot a már felhalmozott argumentumhoz, vagy hozz létre egy új argumentumot. M-- egy negatív argumentumot hoz létre.

univerzális argumentum
Mindig, ha ezt futtatod, az argumentum számláló 4-gyel szorzódik. Az argumentum számláló kezdetben egy, így ennek a funkciónak futtatása elõször beállítja az argumentum számlálóját 4-re. Alapbeállításban nincs hozzá billentyûkombináció rendelve.

Kiegészítés

kiegészít (TAB)
Megpróbálja kiegészíteni a szöveget egy pont elõtt. A Bash megpróbálja kiegészíteni úgy, hogy a szöveget megpróbálja változóként (ha a szöveg $ -vel kezdõdik), felhasználónévként (ha a szöveg ~ -vel kezdõdik), hostnévként (ha a szöveg @ -vel kezdõdik), vagy parancsként (függvények és aliasok) kezelni. Ha ezek közül egyikkel sem egyezik, akkor filenévre egészít ki.

lehetséges kiegészítések (M-?)
Kilistázza a szöveg adott pontja elõtti lehetséges kiegészítéseit.

beszúró kiegészítések
Beszúr minden kiegészítést a szöveg adott pontja elé, amit a lehetséges kiegészítésekkel már legeneráltunk. Alapesetben nincs hozzá billentyûkombináció rendelve.

filenév kiegészítés (M-/)
Megpróbálja kiegészíteni a filenevet a szöveg adott pontja elött.

lehetséges filenév kiegeszítések (C-x /)
Kilistázza a szöveg adott pontja elõtti lehetséges kiegeszítéseket, úgy bánva vele, mintha egy filenév lenne.

felhasználónév kiegészítés (M-~)
Megpróbálja kiegészíteni a szöveget egy adott pontja elõtt, úgy bánva vele, mintha egy felhasználónév lenne.

lehetséges felhasználónév kiegeszítések (C-x ~)
Kilistázza a szöveg adott pontja elõtti lehetséges kiegeszítéseket, úgy bánva vele, mintha egy felhasználónév lenne.

változó kiegészítés (M-$)
Megpróbálja kiegészíteni a szöveget egy adott pontja elõtt, úgy bánva vele, mintha egy shell változó lenne.

lehetséges változó kiegeszítések (C-x $)
Kilistázza a szöveg adott pontja elõtti lehetséges kiegészítéseket, úgy bánva vele, mintha egy shell változó lenne.

hostnév kiegészítés (M-@)
Megpróbálja kiegészíteni a szöveget egy adott pontja elõtt, úgy bánva vele, mintha egy hostnév lenne.

lehetséges hostnév kiegeszítések (C-x @)
Kilistázza a szöveg adott pontja elõtti lehetséges kiegészítéseket, úgy bánva vele, mintha hostnév lenne.

parancs kiegészítés (M-!)
Megpróbálja kiegészíteni a szöveget egy adott pontja elõtt, úgy bánva vele, mintha egy parancs lenne. A parancs kiegészítés megpróbálja megkeresni az egyezõ aliasokat, fenntartott szavakat, shell függvényeket, és végül a futtathatõ fileneveket, ebben a sorrendben.

lehetséges parancs kiegeszítesek (C-x !)
Kilistázza a szöveg adott pontja elõtti lehetséges kiegészítéseket úgy bánva vele, mintha egy parancs lenne.

dinamikus kiegészítõ történeti lista (M-TAB)
Megpróbálja kiegeszíteni a szöveget adott pontja elõtt, összehasonlítva a szöveget a történeti lista soraival, keresve az azonosságokat.

kiegeszítés kapcsos zárójelekbe (M-{)
Egy filenév kiegészítést próbál, és visszaadja a lehetséges kiegészítéseket kapcsos zarójelekbe zárva, így a lista elérhetõ a shellben (nézd meg a Brace Expansion részt feljebb).

Billentyû makrók

billentyûzet makró indítás (C-x ()
Megkezdi a jelenlegi karakter makróba begépelt karakterek mentését.

billenyûzet makró befejezés (C-x ))
Befejezi a jelenlegi karakter makróba begépelt karakterek mentését, és lementi a definíciót.

utolsó billenyûzet makró meghívás (C-x e)
Újra végrehajtja az utolsó definiált billentyûzet makrót, meghozzá úgy, hogy végrehajtja a makró karaktereit úgy, mintha a billenyûzeten gépelték volna be.

Egyebek (Miscellaneous)

az init-file (újra)olvasása (C-x C-r)
(Újra) értelmezi az init-file-beli shortcut-okat, és változó-kijelöléseket.

megszakítás (C-g)
Megszakítja az aktuális szerkesztõ parancsot és csönget egyet (a csöngetés-fajta (bell-style) beállításának megfelelõen).

nagybetûs parancs (M-a, M-b, ...)
Lefuttatja a megfelelõ nagybetûhöz rendelt parancsot.

meta-prefix (ESC)
A következõ begépelt karakterbõl metakaraktert csinál. Így ESC f ugyanaz, mint Meta-f.

visszacsinálás (undo) (C-_, C-x C-u)
Meg szûnteti az elõzõleg kiadott parancsok hatását. Elõször a legutóbbiét, aztán az azt megelõzõét, és így tovább ...

kiinduló állapotba (M-r)
Az adott soron végzett összes változtatást visszacsinálja. Pont olyan, mintha addig undo-znánk, amíg vissza nem jutunk a kiinduló állapotba.

tilde-kiterjesztés (M-~)
Végrehajtja a tilde-kiterjesztést az aktuális szón.

funkciók kiírása (dump-functions)
Kiírja az összes funkciót a hozzá tartozó billentyûkombinációval a readline kimenetére. Ha egy numerikus argumentum van megadva, akkor a kimenetet formázza az inputrc formátumának megfelelõen.

shell verziószám (C-x C-v)
Információt ír ki az épp futó bash verziószámáról.

TÖRTÉNET

A shell lehetõséget ad arra, hogy elõhozzuk az elõzõleg beírt parancsainkat egy parancs-történet (command history) nevû listából. Ez a lista az utolsó HISTSIZE (alapértelmezésben 500) darab parancssor szövegét tárolja. A shell úgy tárolja az egyes sorokat, hogy még nem helyettesítette be a környezeti változókat és a paramétereket (lásd feljebb: EXPANSION), de a történet-kibõvítést már végrehajtotta, a command_oriented_history és a HISTCONTROL shell változók értékének megfelelõen. Legelõször a parancs-történet a HISTFILE nevû változóval meghatározott file-ból inicializálja magát (alapértelmezésben ez a ~/.bash_history). A HISTFILE-ben nem lehet több sor a HISTFILESIZE-ben tárolt értéknél, ezért - ha szükséges a vége levágódik. A beépített fc parancs (lásd alább: SHELL BUILTIN COMMANDS) segítségével megnézhetõ, szerkeszthetõ ill. újra futtatható a történet-lista tetszõleges részlete. A beépített history parancs segítségével szintén a történet-lista manipulálható. Ha parancssorban szerkeszt , a keresõ parancsok minden szerkesztõ módban rendelkezésre állnak. Ennek révén hozzáférhet a történet-lista tetszöleges sorához. Mielõtt a shell kilép, bemásolja a történet-lista utolsó HISTSIZE darab sorát a HISTFILE-be. Ha a HISTFILE változó nincs beállítva, vagy a beállított file nem írható, akkor a shell nem menti a történet-listát.

TÖRTÉNET-KIBÔVÍTÉS

A shell támogatja a csh-belihez hasonló ún. történet-kibõvítési lehetõséget. Ez a fejezet arról szól, hogy milyen szintaktikai lehetõségeket támogat ez a rendszer. Az interaktív shell-ekben ez a funkció alapból engedélyezve van, de letiltható a set (lásd alább: SHELL BUILTIN COMMANDS) parancs \+H kapcsolójával. A nem-interaktív shellek nem támogatják a történet-kibõvítést.

Magát a történet-kibõvítést akkor hajtja végre a shell, mikor már beolvasta a teljes sort, de még nem tördelte szavakra. Két részbõl áll. Elõször eldönteni, hogy melyik korábbi parancssort kell használni a helyettesítéskor (=kibõvítéskor). Aztán kiválasztja ennek a sornak bizonyos részleteit, melyeket majd az aktuális sorba illeszt. A kiválasztott korábbi parancssor az ún. esemény (event), a részletei pedig az ún. szavak (words) A sort ugyanúgy tördeli szavakra, mint sima beolvasáskor, azaz bármi, ami idézöjelek között van egy szónak számít. Csak a backslash (\) és a szimpla idézõjel (') képes a történet-kibõvítés vezérlõkarakterét, a (!)-t hatástalanítani. A történet-kibõvítés által használt különféle karakterek a histchars (lásd feljebb: "Shell Variables") segítségével be- és átállíthatók.

Eseménykijelölõk

Az eseménykijelölõk mind a történet-lista egy korábbi sorára utalnak.

!
A történet-kibõvítés kezdökaraktere. (kivéve ha space, újsor, = vagy csukó zárójel követi.)

!!
A megelõzõ parancssort azonosítja. Ugyanaz, mint `!-1'.

!n
Az n. parancssort azonosítja.

!-n
Az n-nel ezelõtti sort azonosítja.

!karakterlánc
A karakterlánccal kezdõdõ sorok közül a legutóbbit azonosítja.

!?karakterlánc[?]
A karakterláncot tartalmazó sorok közül a legutóbbit azonosítja.

^karakterlánc1^karakterlánc2^
Gyors helyettesítés: megismétli az utolsó parancsot behelyettesítve karakterlánc1 helyére karakterlánc2-t. Ugyanaz, mint ``!!:s/karakterlánc1/karakterlánc2/'' (lásd alább: Modifiers).

!#
Az eddig begépelt teljes parancssor.

Szó Jelölõk

A : elválasztja az esemény leírást a szó jelölõtöl. Elhagyható, ha a szó jelölõ az alábbiak egyikével kezdõdik: ^ , $ , * , vagy % . A szavakat a sor elejétõl számozzuk, az elsõ szó kapja a 0 (nulla) sorszámot.

0 (nulla)
A nulladik szó, a shell ezen a parancsszót érti.

n
Az n-edik szó.

^
Az elsõ argumentum, azaz az 1-es számú szó.

$
Az utolsó argumentum.

%
A legutóbbi `?string?' keresés által talált szó.

x-y
Egy szóintervallum; a `-y' `0-y'-t jelenti.

*
A nulladikon kívûl az összes szó. Ez az `1-$' szinonimája. Nem okoz hibát a * használata, ha csak egy szó van az eseményben; ebben az esetben az üres string-et kapjuk eredménynek.

x*
x-$ rövidítése.

x-
Szintén x-$ rövidítése, mint a x*, azzal a különbséggel, hogy itt elhagyjuk az utolsó szót.

Módosítók

Az opcionális szó jelölõk után fûzhetjük a következõ módosítók sorozatát, mindegyik módosítónak ':'-tal kell kezdõdnie.

h
Az utolsó elérési útvonalkomponenst eltávolítja, csak az eleje marad meg.

r
Egy .xxx alakú kiterjesztést eltávolít a végérõl, csak a file nevét hagyja meg.

e
Az utolsó kiterjesztés kivételével mindent elhagy.

t
Elhagyja az elérési útvonal elsõ komponenseit, csak az utolsó marad meg.

p
Kiírja az új parancssort, de nem hajtja végre.

q
A lecserélt szavakat idézetként kezeli, így ezek többet nem lesznek lecserélve.

x
A lecserélt szavakat a q -hoz hasonlóan idézetként kezeli, de szavakra és sorokra bontja ezeket.

s/régi/új/
Az újat teszi a régi elsõ megjelenésének helyére az eseménysorban. A / jel helyett bármilyen elválasztót használhatunk. Az utolsó elválasztó opcionális ha ez az eseménysor utolsó karaktere. Az elválasztó jelet (mint nem speciális karaktert) használhatjuk újban illetve régiben, ha elé egy \ jelet írunk. Az újba írt & jel helyére a régi kerül. Az & jelet (mint nem speciális karaktert) a \ önmagában jelöli.

&
Megismétli az elõzõ helyettesítést.

g
A változtatásokat az egész eseménysorban végrehajtja. Ezt a `:s' módosítóval együtt használjunk, (pl. `:gs/régi/új/') illetve a `:&'-del. Ha `:s'-sel használjuk, / helyére bármely elválasztójelet írhatunk, az utolsó elválasztójel opcionális, ha ez az eseménysor utolsó karaktere.

ARITHMETIC EVALUATION

The shell allows arithmetic expressions to be evaluated, under certain circumstances (see the let builtin command and Arithmetic Expansion). Evaluation is done in long integers with no check for overflow, though division by 0 is trapped and flagged as an error. The following list of operators is grouped into levels of equal-precedence operators. The levels are listed in order of decreasing precedence.

- +
unary minus and plus

! ~
logical and bitwise negation

* / %
multiplication, division, remainder

+ -
addition, subtraction

<< >>
left and right bitwise shifts

<= >= < >
comparison

== !=
equality and inequality

&
bitwise AND

^
bitwise exclusive OR

|
bitwise OR

&&
logical AND

||
logical OR

= *= /= %= += -= <<= >>= &= ^= |=
assignment

Shell variables are allowed as operands; parameter expansion is performed before the expression is evaluated. The value of a parameter is coerced to a long integer within an expression. A shell variable need not have its integer attribute turned on to be used in an expression.

Constants with a leading 0 are interpreted as octal numbers. A leading 0x or 0X denotes hexadecimal. Otherwise, numbers take the form [base#]n, where base is a decimal number between 2 and 36 representing the arithmetic base, and n is a number in that base. If base is omitted, then base 10 is used.

Operators are evaluated in order of precedence. Sub-expressions in parentheses are evaluated first and may override the precedence rules above.

SHELL BUILTIN COMMANDS

: [arguments]
No effect; the command does nothing beyond expanding arguments and performing any specified redirections. A zero exit code is returned.

. filename [arguments]

source filename [arguments]
Read and execute commands from filename in the current shell environment and return the exit status of the last command executed from filename . If filename does not contain a slash, pathnames in PATH are used to find the directory containing filename . The file searched for in PATH need not be executable. The current directory is searched if no file is found in PATH . If any arguments are supplied, they become the positional parameters when file is executed. Otherwise the positional parameters are unchanged. The return status is the status of the last command exited within the script (0 if no commands are executed), and false if filename is not found.

alias [name[=value] ...]
Alias with no arguments prints the list of aliases in the form name=value on standard output. When arguments are supplied, 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 when the alias is expanded. For each name in the argument list for which no value is supplied, the name and value of the alias is printed. Alias returns true unless a name is given for which no alias has been defined.

bg [jobspec]
Place jobspec in the background, as if it had been started with & . If jobspec is not present, the shell's notion of the current job is used. bg jobspec returns 0 unless run when job control is disabled or, when run with job control enabled, if jobspec was not found or started without job control.

bind [-m keymap] [-lvd] [-q name]

bind [-m keymap] -f filename

bind [-m keymap] keyseq:function-name
Display current readline key and function bindings, or bind a key sequence to a readline function or macro. The binding syntax accepted is identical to that of .inputrc , but each binding must be passed as a separate argument; e.g., '"\C-x\C-r": re-read-init-file'. Options, if supplied, have the following meanings:

-m keymap
Use keymap as the keymap to be affected by the subsequent bindings. Acceptable keymap names are emacs, emacs-standard, emacs-meta, emacs-ctlx, vi, vi-move, vi-command, and vi-insert . vi is equivalent to vi-command; emacs is equivalent to emacs-standard.

-l
List the names of all readline functions

-v
List current function names and bindings

-d
Dump function names and bindings in such a way that they can be re-read

-f filename
Read key bindings from filename

-q function
Query about which keys invoke the named function

The return value is 0 unless an unrecognized option is given or an error occurred.

break [n]
Exit from within a for , while , or until loop. If n is specified, break n levels. n must be \(>= 1. If n is greater than the number of enclosing loops, all enclosing loops are exited. The return value is 0 unless the shell is not executing a loop when break is executed.

builtin shell-builtin [arguments]
Execute the specified shell builtin, passing it arguments , and return its exit status. This is useful when you wish to define a function whose name is the same as a shell builtin, but need the functionality of the builtin within the function itself. The cd builtin is commonly redefined this way. The return status is false if shell-builtin is not a shell builtin command.

cd [dir]
Change the current directory to dir. The variable HOME is the default dir . The variable CDPATH defines the search path for the directory containing dir . Alternative directory names are separated by a colon (:). A null directory name in CDPATH is the same as the current directory, i.e., ``.''. If dir begins with a slash (/), then CDPATH is not used. An argument of - is equivalent to $OLDPWD . The return value is true if the directory was successfully changed; false otherwise.

command [-pVv] command [arg ...]
Run command with args suppressing the normal shell function lookup. Only builtin commands or commands found in the PATH are executed. If the -p option is given, the search for command is performed using a default value for PATH that is guaranteed to find all of the standard utilities. If either the -V or -v option is supplied, a description of command is printed. The -v option causes a single word indicating the command or pathname used to invoke command to be printed; the -V option produces a more verbose description. An argument of -- disables option checking for the rest of the arguments. If the -V or -v option is supplied, the exit status is 0 if command was found, and 1 if not. If neither option is supplied and an error occurred or command cannot be found, the exit status is 127. Otherwise, the exit status of the command builtin is the exit status of command .

continue [n]
Resume the next iteration of the enclosing for , while , or until loop. If n is specified, resume at the nth enclosing loop. n must be \(>= 1. If n is greater than the number of enclosing loops, the last enclosing loop (the `top-level' loop) is resumed. The return value is 0 unless the shell is not executing a loop when continue is executed.

declare [-frxi] [name[=value]]

typeset [-frxi] [name[=value]]
Declare variables and/or give them attributes. If no names are given, then display the values of variables instead. The options can be used to restrict output to variables with the specified attribute.

-f
Use function names only

-r
Make names readonly. These names cannot then be assigned values by subsequent assignment statements.

-x
Mark names for export to subsequent commands via the environment.

-i
The variable is treated as an integer; arithmetic evaluation (see "ARITHMETIC EVALUATION" ") " is performed when the variable is assigned a value.

Using `+' instead of `-' turns off the attribute instead. When used in a function, makes names local, as with the local command. The return value is 0 unless an illegal option is encountered, an attempt is made to define a function using "-f foo=bar", one of the names is not a legal shell variable name, an attempt is made to turn off readonly status for a readonly variable, or an attempt is made to display a non-existant function with -f.

dirs [-l] [+/-n]
Display the list of currently remembered directories. Directories are added to the list with the pushd command; the popd command moves back up through the list.

+n
displays the nth entry counting from the left of the list shown by dirs when invoked without options, starting with zero.

-n
displays the nth entry counting from the right of the list shown by dirs when invoked without options, starting with zero.

-l
produces a longer listing; the default listing format uses a tilde to denote the home directory.

The return value is 0 unless an illegal option is supplied or n indexes beyond the end of the directory stack.

echo [-neE] [arg ...]
Output the args, separated by spaces. The return status is always 0. If -n is specified, the trailing newline is suppressed. If the -e option is given, interpretation of the following backslash-escaped characters is enabled. The -E option disables the interpretation of these escape characters, even on systems where they are interpreted by default.

\a
alert (bell)

\b
backspace

\c
suppress trailing newline

\f
form feed

\n
new line

\r
carriage return

\t
horizontal tab

\v
vertical tab

\\
backslash

\nnn
the character whose ASCII code is nnn (octal)

enable [-n] [-all] [name ...]
Enable and disable builtin shell commands. This allows the execution of a disk command which has the same name as a shell builtin without specifying a full pathname. If -n is used, each name is disabled; otherwise, names are enabled. For example, to use the test binary found via the PATH instead of the shell builtin version, type ``enable -n test''. If no arguments are given, a list of all enabled shell builtins is printed. If only -n is supplied, a list of all disabled builtins is printed. If only -all is supplied, the list printed includes all builtins, with an indication of whether or not each is enabled. enable accepts -a as a synonym for -all . The return value is 0 unless a name is not a shell builtin.

eval [arg ...]
The args are read and concatenated together into a single command. This command is then read and executed by the shell, and its exit status is returned as the value of the eval command. If there are no args , or only null arguments, eval returns true.

exec [[-] command [arguments]]
If command is specified, it replaces the shell. No new process is created. The arguments become the arguments to command. If the first argument is - , the shell places a dash in the zeroth arg passed to command . This is what login does. If the file cannot be executed for some reason, a non-interactive shell exits, unless the shell variable no_exit_on_failed_exec exists, in which case it returns failure. An interactive shell returns failure if the file cannot be executed. If command is not specified, any redirections take effect in the current shell, and the return status is 0.

exit [n]
Cause the shell to exit with a status of n. If n is omitted, the exit status is that of the last command executed. A trap on EXIT is executed before the shell terminates.

export [-nf] [name[=word]] ...

export -p
The supplied names are marked for automatic export to the environment of subsequently executed commands. If the -f option is given, the names refer to functions. If no names are given, or if the -p option is supplied, a list of all names that are exported in this shell is printed. The -n option causes the export property to be removed from the named variables. An argument of -- disables option checking for the rest of the arguments. export returns an exit status of 0 unless an illegal option is encountered, one of the names is not a legal shell variable name, or -f is supplied with a name that is not a function.

fc [-e ename] [-nlr] [first] [last]

fc -s [pat=rep] [cmd]
Fix Command. In the first form, a range of commands from first to last is selected from the history list. First and last may be specified as a string (to locate the last command beginning with that string) or as a number (an index into the history list, where a negative number is used as an offset from the current command number). If last is not specified it is set to the current command for listing (so that fc -l -10 prints the last 10 commands) and to first otherwise. If first is not specified it is set to the previous command for editing and -16 for listing.

The -n flag suppresses the command numbers when listing. The -r flag reverses the order of the commands. If the -l flag is given, the commands are listed on standard output. Otherwise, the editor given by ename is invoked on a file containing those commands. If ename is not given, the value of the FCEDIT variable is used, and the value of EDITOR if FCEDIT is not set. If neither variable is set, vi is used. When editing is complete, the edited commands are echoed and executed.

In the second form, command is re-executed after each instance of pat is replaced by rep. A useful alias to use with this is ``r=fc -s'', so that typing ``r cc'' runs the last command beginning with ``cc'' and typing ``r'' re-executes the last command.

If the first form is used, the return value is 0 unless an illegal option is encountered or first or last specify history lines out of range. If the -e option is supplied, the return value is the value of the last command executed or failure if an error occurs with the temporary file of commands. If the second form is used, the return status is that of the command re-executed, unless cmd does not specify a valid history line, in which case fc returns failure.

fg [jobspec]
Place jobspec in the foreground, and make it the current job. If jobspec is not present, the shell's notion of the current job is used. The return value is that of the command placed into the foreground, or failure if run when job control is disabled or, when run with job control enabled, if jobspec does not specify a valid job or jobspec specifies a job that was started without job control.

getopts optstring név [args]
getopts parancsot shell eljárások használják pozicionális paraméterek elemzéséhez.Az optstring opció betûket tartalmaz, amiket fel kell ismerni; ha a betût kettõspont követi, az opciónak változója van, amit egy szeparáló karakternek kell elválasztania az opciótól. Valahányszor ez végrehajtódik, getopts a következõ opciót berakja a név shell változóba, inicializálva a név változót, ha az nem létezik, és a következö változóba feldolgozandó argumentum indexe OPTIND lesz. OPTIND mindig 1-re inicializálódik, valahányszor a shell vagy shell script meghívódik. Mikor egy opciónak argumentum kell, getopts az OPTARG változóba teszi az argumentumot. A shell nem állítja újra az OPTIND -ot automatikusan; manuálisan kell utána állítani a többszörös getopts hívások között, a shell ugyanazon meghívásánál, ha új paraméter halmazt használunk.

A getopts kétféleképpen tudja a hibát jelezni. Ha az optstring elsõ karaktere kettõspont, csendes hibajelzést ad. Normális esetben akkor küld hibaelemzõ üzeneteket, ha érvénytelen opciókat vagy hiányzó opció argumentumokat talál. Ha az OPTERR változó 0-ra van állítva, nem küld hibaüzeneteket, még akkor sem, ha az optstring elsõ karaktere nem kettõspont.

Ha érvénytelen opciót talál, getopts kérdõjelet rak a névbe, és ha nem csendes a hibajelzés, kiírja a hibaüzeneteket, valamint nullázza az OPTARG értékét. Ha a getopts csendes, akkor a talált opció karakter az OPTARG -ban helyezõdik el, és nem ír ki hibaelemzõ üzeneteket.

Ha egy szükséges argumentum nem talalható, és a getopts nem csendes, egy kerdõjelet (?) helyez el a névben,az OPTARG törlõdik, és egy hibaelemzõ üzenet iródik ki. Ha a getopts csendes, egy kettõspontot (:) rak a névbe, és az OPTARG változót beállítja a talált opció karakerre.

A getopts általában elemzi a pozicionális paramétereket, de ha több argumentum van az args-ban megadva, getopts elemzi azokat is. A getopts igazat ad vissza, ha talál egy opciót (akár specifikált, akár nem). Hamis értékkel tér vissza, ha eléri az opciók végét, vagy hibát talál.

[B

hash [-r] [név]
Minden névhez, a parancs teljes elérési utját meghatározza és eltárolja. A -r opció minden eddigi megjegyzett helyet elfelejtet a shellel. Ha nincs argumentum megadva, akkor a megjegyzettzett parancsokat irja ki. A -- egy argumentuma kikapcsolja a további argumentumok vizsgálatát. A visszatérési státusz igaz, kivéve ha a név nem található, vagy egy illegális opciót hajottak végre.

help [minta]
Megjelenít egy hasznos információt a beépített paracsokról. Ha megadunk mintát, a help egy részletes segítséget ad az összes parancsról, ami egyezzik a mintával, máskülönben ad egy listát a beépített parancsokról. A visszatérési státusz 0, kivéve, ha egyetlen parancs sem felel meg a mintának.

history [n]

history -rwan [filenév]
Opciók nélkül megjeleníti a parancs-történetet sorszámokkal. A * -gal listázott sorok lettek módosítva. Ha megadjuk az n argumentumot, csak az utolsó n sort listázza ki. Ha egy nem-opcionalis argumentumot alkalmazunk, akkor ezt úgy használja, mint egy történet file-t, egyébként, a HISTFILE értékét használja. Az opcióknak alkalmazáskor a következõ jelentése van:

-a
Kiírja az ``új'' történet sorokat (a legutolsó bash session által beírt parancsok kezdetétõl) a történet file-ba.

-n
Beolvassa a még be nem olvasott történet sorokat a tórtenet file-ból a jelenlegi tórténet listába. Ezek azok a sorok, amik az utolsó bash session kezdete óta lettek a file-ba beleírva.
-r
A történet file-t olvassa, és aktuális parancsként használja tartalmát.
-w
Az aktuális parancsot beírja a történet file-ba, felülírván ezzel a lista tartalmát.

A visszatérési érték nulla, feltéve, ha nincs érvénytelen opció beállítva, illetve ha nem lép fel hiba a történet file írása, olvasása közben.

jobs [-lnp] [ jobspecifikáció ... ]

jobs -x parancs [ argumentumok ... ]
Elsõ formájában az aktív job-okat listázza ki. A -l opció a szokásos információk mellett a processzazonosítókat is megjeleníti; a -p opció azonban csak a job processzcsoport-vezetõjének processzazonosítóját. Az -n opció kizárólag azokat a job-okat jeleníti meg, amelyek státusza az utolsó megfigyelés óta változott. jobspecifikáció megadása esetén a kimenet a megadott job-bal kapcsolatos információra szorítkozik. A visszatérési státusz nulla, ha nincs érvénytelen opció, vagy érvénytelen jobspecifikáció megadva.
Az -x opció megadásával a jobs valamennyi jobspecifikáció-elõfordulást a parancs-ban vagy argumentum-ban a megegyezõ processzcsoport-azonosítóval cseréli ki, és futtatja a parancs-ot az argumentum-ával, annak kilépési státuszát adva vissza.

kill [-s jelspecifikáció | -jelspecifikáció] [processzazonosító | jobspecifikáció] ...

kill -l [jelszám]
A jelspecifikáció-jelet elküldi a processzazonosító-val vagy jobspecifikációval meghatározott processzeknek. A jelspecifikáció lehet jelnév, mint a SIGKILL, vagy jelszám. Ha a jelspecifikáció jelnév, a név megadható a SIG elõtaggal és anélkül is. Ha a jelspecifikáció nincs megadva, akkor a SIGTERM feltételezett. A -l argumentum a jelneveket listázza ki. A -l bármely más argumentummal együtt a specifikált jelek neveit listázza ki, és a visszatérési státusz nulla. A -- argumentum az õt követõ argumentumok ellenõrzését hagyja el. A kill visszatérési értéke true, ha az utolsó jelet is sikeresen elküldte, és false, ha hiba történt, vagy érvénytelen opciót talált.

let argumentum [argumentum ...]
Minden argumentum kiszámolandó aritmetikai kifejezés (lásd "ARITHMETIC EVALUATION" ). Ha az utolsó argumentum eredménye nulla, a let egyet ad viszza; ellenkezõ esetben nullát.

local [vátozónév[=érték] ...]
Minden argumentumhoz létrehoz egy változónév nevû logikai változót, és hozzárendeli az érték-et. Ha a local-t függvényen belül használjuk, a név változónak a láthatósága az adott függvényre és annak gyermekeire korlátozódik. Operandus nélkül a local a lokális változók listáját írja ki a standard kimentre. Hiba keletkezik, ha függvényen kívül akarunk local-t használni. A visszatérési státusz nulla, hacsak a local-t egy külsõ függvény nem használja, vagy egy érvénytelen opció nincs megadva.

logout
Kilép egy login shell-bõl.

popd [+/-n]
Elemeket vesz ki a könyvtárverembõl. Argumentum nélkül kiveszi a legfelsõ könyvtárat a verembõl, és belép a cd parancssal az így kapott legfelsõ könyvtárba.

+n
a dirs által mutatott listából balról számolva (nullától kezdve) az n-ediket kiveszi. Például: ``popd +0'' az elsõ könyvtárat veszi ki, ``popd +1'' a másodikat.
-n
a dirs által mutatott listából jobbról számolva (nullától kezdve) az n-ediket kiveszi. Például: ``popd -0'' az utolsó könyvtárat veszi ki, ``popd -1'' az utolsó elõttit.

Ha a popd parancs sikeres volt, azt a dirs is megmutatja, és a visszatérõ státusz nulla. A popd false-szal tér vissza, ha nem megfelelõ az opció megadása, ha üres a könyvtárverem, ha nem létezõ a könyvtár-specifikáció, vagy ha nem sikerül a könyvtárváltoztatás.

pushd [könyvtár]

pushd +/-n
Egy könyvtárat tesz a könyvtárverem tetejére, vagy rotálja a vermet, úgy, hogy az aktuális munkakönyvtárat a verem tetejére helyezi. Argumentum nélkül felcseréli a két legfelsõ könyvtárat, és nullával tér vissza, ha nem üres a könyvtárverem.

+n
Rotates the stack so that the nth directory (counting from the left of the list shown by dirs ) is at the top.

-n
Rotates the stack so that the nth directory (counting from the right) is at the top.

dir
adds dir to the directory stack at the top, making it the new current working directory.

If the pushd command is successful, a dirs is performed as well. If the first form is used, pushd returns 0 unless the cd to dir fails. With the second form, pushd returns 0 unless the directory stack is empty, a non-existant directory stack element is specified, or the directory change to the specified new current directory fails.

pwd
Print the absolute pathname of the current working directory. The path printed contains no symbolic links if the -P option to the set builtin command is set. See also the description of nolinks under Shell Variables above). The return status is 0 unless an error occurs while reading the pathname of the current directory.

read [-r] [name ...]
One line is read from the standard input, and the first word is assigned to the first name , the second word to the second name , and so on, with leftover words assigned to the last name . Only the characters in IFS are recognized as word delimiters. If no names are supplied, the line read is assigned to the variable REPLY . The return code is zero, unless end-of-file is encountered. If the -r option is given, a backslash-newline pair is not ignored, and the backslash is considered to be part of the line.

readonly [-f] [name ...]

readonly -p
The given names are marked readonly and the values of these names may not be changed by subsequent assignment. If the -f option is supplied, the functions corresponding to the names are so marked. If no arguments are given, or if the -p option is supplied, a list of all readonly names is printed. An argument of -- disables option checking for the rest of the arguments. The return status is 0 unless an illegal option is encountered, one of the names is not a legal shell variable name, or -f is supplied with a name that is not a function.

return [n]
Causes a function to exit with the return value specified by n . If n is omitted, the return status is that of the last command executed in the function body. If used outside a function, but during execution of a script by the . (source) command, it causes the shell to stop executing that script and return either n or the exit status of the last command executed within the script as the exit status of the script. If used outside a function and not during execution of a script by ., the return status is false.

set [--abefhkmnptuvxldCHP] [-o option] [arg ...]

-a
Automatically mark variables which are modified or created for export to the environment of subsequent commands.

-b
Cause the status of terminated background jobs to be reported immediately, rather than before the next primary prompt. (Also see notify under Shell Variables above).

-e
Exit immediately if a simple-command (see SHELL GRAMMAR above) exits with a non-zero status. The shell does not exit if the command that fails is part of an until or while loop, part of an if statement, part of a && or || list, or if the command's return value is being inverted via ! .

-f
Disable pathname expansion.

-h
Locate and remember function commands as functions are defined. Function commands are normally looked up when the function is executed.

-k
All keyword arguments are placed in the environment for a command, not just those that precede the command name.

-m
Monitor mode. Job control is enabled. This flag is on by default for interactive shells on systems that support it (see JOB CONTROL above). Background processes run in a separate process group and a line containing their exit status is printed upon their completion.

-n
Read commands but do not execute them. This may be used to check a shell script for syntax errors. This is ignored for interactive shells.

-o option-name
The option-name can be one of the following:

allexport
Same as -a .

braceexpand
The shell performs brace expansion (see Brace Expansion above). This is on by default.

emacs
Use an emacs-style command line editing interface. This is enabled by default when the shell is interactive, unless the shell is started with the -nolineediting option.

errexit
Same as -e .

histexpand
Same as -H .

ignoreeof
The effect is as if the shell command `IGNOREEOF=10' had been executed (see Shell Variables above).

interactive-comments
Allow a word beginning with # to cause that word and all remaining characters on that line to be ignored in an interactive shell (see COMMENTS above).

monitor
Same as -m .

noclobber
Same as -C .

noexec
Same as -n .

noglob
Same as -f .

nohash
Ugyanaz, mint -d .

notify
Ugyanaz, mint -b .

nounset
Ugyanaz, mint -u .

physical
Ugyanaz, mint -P .

posix
A bash viselkedését a szabványhoz igazítja azon esetekben, amikor az alapértelmezett mûvelet különbözik a Posix 1003.2 szabványtól.

privileged
Ugyanaz, mint -p .

verbose
Ugyanaz, mint -v .

vi
vi-stílusú parancssori szerkesztõfelület használata.

xtrace
Ugyanaz, mint -x .

Ha kapcsolónév nincs megadva, a jelenlegi kapcsolók értékei kerülnek kiírásra.

-p
A privileged üzemmód bekapcsolása. Ebben az üzemmódban a $ENV fájl nem kerül feldolgozásra, a shell funkciói pedig nem öröklõdnek a környezetbõl. Ez indításkor önmûködõen bekapcsolódik, ha az effektív felhasználó- (csoport-) azonosító nem azonos a valódi felhasználó- (csoport-) azonosítóval. A kapcsoló kikapcsolására az effektív felhasználó- és csoportazonosítók a valódiakra állítódnak be.

-t
Kilépés egyetlen parancs beolvasása és végrehajtása után.

-u
Paraméterkifejtéskor a nem beállított változókat hibaként kezeli. Ha nem beállított változót próbál kifejteni, a shell hibaüzenetet ír ki, és ha nem párbeszédes üzemmódban van, nemnulla státusszal kilép.

-v
A shell bemenõ sorait beolvasáskor kiírja.

-x
Minden egyes egyszerû-parancs kifejtése után a bash megjeleníti a PS4 kifejtett értékét, amelyet a parancs és kifejtett argumentumai követnek.

-l
Elmenti és visszaállítja a név értékét a for név [in szó] parancsban (lásd SHELL GRAMMAR fent)

-d
A végrehajtáskor kikeresett parancsok hashingelésének kikapcsolása. A parancsok rendes körülmények között hashtáblába kerülnek, és csak egyszer kell õket megkeresni.

-C
A hatása ugyanaz, mint ha a shell `noclobber=' parancsa került volna végrehajtásra (lásd Shell variables fent).

-H
A ! stílusú történet-helyettesítés bekapcsolása. Ez a jelzõ (flag) alapértelmezés szerint be van állítva, ha a shell párbeszédes üzemmódban van.

-P
Beállítása azt eredményezi, hogy a szimbolikus csatolások nem lesznek követve olyan parancsok, pl. cd végrehajtásakor, amelyek megváltoztatják az aktuális alkönyvtárt. Helyettük a fizikai alkönyvtár kerül felhasználásra.

--
Ha ezt a jelzõt (flag-et) nem követi argumentum, akkor a pozicionális paraméterek nem állítódnak be. Egyébként a pozicionális paraméterek argumentumoknak állítódnak be, még akkor is, ha van köztük olyan, amely - jellel kezdõdik.

-
A kapcsolók végét jelzi, hatására az összes hátralévõ argumentum a pozicionális paramétereknek osztódik ki. A -x és a -v kapcsolók nincsenek bekapcsolva. Ha nincsenek argumentumok, a pozicionális paraméterek változatlanok maradnak.

Egyéb jelzés hiányában a jelzõk (flagek) alapértelmezett esetben nincsenek bekapcsolva. A - jel helyett a + jel használatára ezek a jelzõk (flagek) kikapcsolódnak. A flagek a shell egy meghívásának kapcsolóiként is megadhatók. A flagek jelenlegi beállításait $- tartalmazza. A kapcsoló után az argumentumok kerülnek feldolgozásra, a hatralévõ n argumentum pedig a pozicionális paraméterek értékeiként kezelõdik, és ilyen sorrendben $1 , $2 , ... $n tartalmazza õket. Ha sem kapcsoló, sem argumentum nincs megadva, az összes shellváltozó kiíródik. A visszatérési státusz mindig igaz,kivéve, ha illegális kapcsolóba ütközött a shell.

shift [n]
The positional parameters from n+1 ... are renamed to $1 .... Parameters represented by the numbers $# down to $#-n+1 are unset. If n is 0, no parameters are changed. If n is not given, it is assumed to be 1. n must be a non-negative number less than or equal to $#. If n is greater than $#, the positional parameters are not changed. The return status is greater than 0 if n is greater than $# or less than 0; otherwise 0.

suspend [-f]
Suspend the execution of this shell until it receives a SIGCONT signal. The -f option says not to complain if this is a login shell; just suspend anyway. The return status is 0 unless the shell is a login shell and -f is not supplied, or if job control is not enabled.

test expr

[ expr ]
Return a status of 0 (true) or 1 (false) depending on the evaluation of the conditional expression expr . Expressions may be unary or binary. Unary expressions are often used to examine the status of a file. There are string operators and numeric comparison operators as well. Each operator and operand must be a separate argument. If file is of the form /dev/fd/n, then file descriptor n is checked.

-b file
True if file exists and is block special.

-c file
True if file exists and is character special.

-d file
True if file exists and is a directory.

-e file
True if file exists.

-f file
True if file exists and is a regular file.

-g file
True if file exists and is set-group-id.

-k file
True if file has its ``sticky'' bit set.

-L file
True if file exists and is a symbolic link.

-p file
True if file exists and is a named pipe.

-r file
True if file exists and is readable.

-s file
True if file exists and has a size greater than zero.

-S file
True if file exists and is a socket.

-t fd
True if fd is opened on a terminal.

-u file
True if file exists and its set-user-id bit is set.

-w file
True if file exists and is writable.

-x file
True if file exists and is executable.

-O file
True if file exists and is owned by the effective user id.

-G file
True if file exists and is owned by the effective group id.

file1 -nt file2
True if file1 is newer (according to modification date) than file2.

file1 -ot file2
True if file1 is older than file2.

file1 -ef file
True if file1 and file2 have the same device and inode numbers.

-z string
True if the length of string is zero.

-n string

string
True if the length of string is non-zero.

string1 = string2
True if the strings are equal.

string1 != string2
True if the strings are not equal.

! expr
True if expr is false.

expr1 -a expr2
True if both expr1 AND expr2 are true.

expr1 -o expr2
True if either expr1 OR expr2 is true.

arg1 OP arg2
OP is one of -eq , -ne , -lt , -le , -gt , or -ge . These arithmetic binary operators return true if arg1 is equal, not-equal, less-than, less-than-or-equal, greater-than, or greater-than-or-equal than arg2, respectively. Arg1 and arg2 may be positive integers, negative integers, or the special expression -l string, which evaluates to the length of string .

times
Print the accumulated user and system times for the shell and for processes run from the shell. The return status is 0.

trap [-l] [arg] [sigspec]
The command arg is to be read and executed when the shell receives signal(s) sigspec . If arg is absent or - , all specified signals are reset to their original values (the values they had upon entrance to the shell). If arg is the null string this signal is ignored by the shell and by the commands it invokes. sigspec is either a signal name defined in <signal.h>, or a signal number. If sigspec is EXIT (0) the command arg is executed on exit from the shell. With no arguments, trap prints the list of commands associated with each signal number. The -l option causes the shell to print a list of signal names and their corresponding numbers. An argument of -- disables option checking for the rest of the arguments. Signals ignored upon entry to the shell cannot be trapped or reset. Trapped signals are reset to their original values in a child process when it is created. The return status is false if either the trap name or number is invalid; otherwise trap returns true.

type [-all] [-type | -path] name [name ...]
With no options, indicate how each name would be interpreted if used as a command name. If the -type flag is used, type prints a phrase which is one of alias , keyword , function , builtin , or file if name is an alias, shell reserved word, function, builtin, or disk file, respectively. If the name is not found, then nothing is printed, and an exit status of false is returned. If the -path flag is used, type either returns the name of the disk file that would be executed if name were specified as a command name, or nothing if -type would not return file . If a command is hashed, -path prints the hashed value, not necessarily the file that appears first in PATH . If the -all flag is used, type prints all of the places that contain an executable named name . This includes aliases and functions, if and only if the -path flag is not also used. The table of hashed commands is not consulted when using -all . type accepts -a , -t , and -p in place of -all , -type , and -path , respectively. An argument of -- disables option checking for the rest of the arguments. type returns true if any of the arguments are found, false if none are found.

ulimit [-SHacdfmstpnuv [limit]]
Ulimit provides control over the resources available to the shell and to processes started by it, on systems that allow such control. The value of limit can be a number in the unit specified for the resource, or the value unlimited . The H and S options specify that the hard or soft limit is set for the given resource. A hard limit cannot be increased once it is set; a soft limit may be increased up to the value of the hard limit. If neither H nor S is specified, the command applies to the soft limit. If limit is omitted, the current value of the soft limit of the resource is printed, unless the H option is given. When more than one resource is specified, the limit name and unit is printed before the value. Other options are interpreted as follows:

-a
all current limits are reported

-c
the maximum size of core files created

-d
the maximum size of a process's data segment

-f
the maximum size of files created by the shell

-m
the maximum resident set size

-s
the maximum stack size

-t
the maximum amount of cpu time in seconds

-p
the pipe size in 512-byte blocks (this may not be set)

-n
the maximum number of open file descriptors (most systems do not allow this value to be set, only displayed)

-u
the maximum number of processes available to a single user

-v
The maximum amount of virtual memory available to the shell

An argument of -- disables option checking for the rest of the arguments. If limit is given, it is the new value of the specified resource (the -a option is display only). If no option is given, then -f is assumed. Values are in 1024-byte increments, except for -t , which is in seconds, -p , which is in units of 512-byte blocks, and -n and -u , which are unscaled values. The return status is 0 unless an illegal option is encountered, a non-numeric argument other than unlimited is supplied as limit, or an error occurs while setting a new limit.

umask [-S] [mode]
The user file-creation mask is set to mode . If mode begins with a digit, it is interpreted as an octal number; otherwise it is interpreted as a symbolic mode mask similar to that accepted by chmod (1). If mode is omitted, or if the -S option is supplied, the current value of the mask is printed. The -S option causes the mask to be printed in symbolic form; the default output is an octal number. An argument of -- disables option checking for the rest of the arguments. The return status is 0 if the mode was successfully changed or if no mode argument was supplied, and false otherwise.

unalias [-a] [name ...]
Remove names from the list of defined aliases. If -a is supplied, all alias definitions are removed. The return value is true unless a supplied name is not a defined alias.

unset [-fv] [name ...]
For each name , remove the corresponding variable or, given the -f option, function. An argument of -- disables option checking for the rest of the arguments. Note that PATH , IFS , PPID , PS1 , PS2 , UID , and EUID cannot be unset. If any of RANDOM , SECONDS , LINENO , or HISTCMD are unset, they lose their special properties, even if they are subsequently reset. The exit status is true unless a name does not exist or is non-unsettable.

wait [n]
Wait for the specified process and return its termination status. n may be a process ID or a job specification; if a job spec is given, all processes in that job's pipeline are waited for. If n is not given, all currently active child processes are waited for, and the return status is zero. If n specifies a non-existant process or job, the return status is 127. Otherwise, the return status is the exit status of the last process or job waited for.

INVOCATION

A login shell is one whose first character of argument zero is a - , or one started with the -login flag.

An interactive shell is one whose standard input and output are both connected to terminals (as determined by isatty (3)), or one started with the -i option. PS1 is set and $- includes i if bash is interactive, allowing a shell script or a startup file to test this state.

Login shells:
  On login (subject to the -noprofile option):
        if /etc/profile exists, source it.

if ~/.bash_profile exists, source it, else if ~/.bash_login exists, source it, else if ~/.profile exists, source it.
On exit: if ~/.bash_logout exists, source it.
Non-login interactive shells: On startup (subject to the -norc and -rcfile options): if ~/.bashrc exists, source it.
Non-interactive shells: On startup: if the environment variable ENV is non-null, expand it and source the file it names, as if the command if [ "$ENV" ]; then . $ENV; fi had been executed, but do not use PATH to search for the pathname. When not started in Posix mode, bash looks for BASH_ENV before ENV.

If Bash is invoked as sh , it tries to mimic the behavior of sh as closely as possible. For a login shell, it attempts to source only /etc/profile and ~/.profile , in that order. The -noprofile option may still be used to disable this behavior. A shell invoked as sh does not attempt to source any other startup files.

When bash is started in posix mode, as with the -posix command line option, it follows the Posix standard for startup files. In this mode, the ENV variable is expanded and that file sourced; no other startup files are read.

LÁSD MÉG

Bash Features, Brian Fox and Chet Ramey

The Gnu Readline Library, Brian Fox and Chet Ramey

The Gnu History Library, Brian Fox and Chet Ramey

A System V Compatible Implementation of 4.2BSD Job Control, David Lennert

Portable Operating System Interface (POSIX) Part 2: Shell and Utilities, IEEE

sh(1), ksh(1), csh(1)

emacs(1), vi(1)

readline(3)

FILE-OK

/bin/bash
A futtatható bash

/etc/profile
Az egész rendszerre vonatkozó inicializációs file, végrehajtja a belépéskor

~/.bash_profile
A személyes inicializációs file, végrehajtja a belépéskor

~/.bashrc
Az egyéni párbeszédes-shell indulásához való adatfile

~/.inputrc
Az egyéni sorolvasóhoz inicializációs file

SZERZŐK

Brian Fox, Free Software Foundation (elsődleges szerző)
bfox@ai.MIT.Edu

Chet Ramey, Case Western Reserve University
chet@ins.CWRU.Edu

HIBA JELENTÉSEK

Ha te találsz egy hibát a bashedben, akkor jelentened kell. De először meg kell bizonyosodnod felőle, hogy az tényleg hiba, és az általad birtokolt legújabb verziójú bashben jelenik meg.

Ha egyszer megállapítottad, hogy a hiba létezik, használd a bashbug parancsot, hogy hibajelentést küldj. Ha találtál megoldást, szintén várjuk leveledet! Javaslatok és `filozófiai' hibajelentéseket lehet küldeni bug-bash@prep.ai.MIT.Edu címre vagy postázni a Usenet hírcsoportnak gnu.bash.bug .

Az összes hibajelentésnek tartalmaznia kell:

A bash verziószámát

A hardvert és operációs rendszert

A fordítót amivel szoktak fordítani

Egy leírást a hiba viselkedéséről

Egy rövid szöveget vagy `receptet' amelyik bemutatja a hiba működését.

A bashbug beilleszti az első három tételt automatikusan a mintába, gondoskodik a hibajelentés iktatásáról.

Az ezzel a Bash-kézikönyv oldallal kapcsolatos megjegyzéseket és hibajelentéseket irányítsd a chet@ins.CWRU.Edu . címre.

HIBÁK

Túl nagy és lassú.

Van néhány apróbb különbség a bash és az sh hagyományos verziói között, a legtöbb a POSIX előírások teljesítése miatt.

Az aliasok néhány használati módja elég zavaró.