Bash Reference Manual Reference Documentation for Bash



Yüklə 4,8 Kb.
Pdf görüntüsü
səhifə22/66
tarix08.10.2017
ölçüsü4,8 Kb.
#3723
1   ...   18   19   20   21   22   23   24   25   ...   66

Chapter 4: Shell Builtin Commands
52
shopt (see Section 4.3.2 [The Shopt Builtin], page 64), the source file name and
line number where each name is defined are displayed as well. -F implies -f.
The -g option forces variables to be created or modified at the global scope,
even when declare is executed in a shell function. It is ignored in all other
cases.
The following options can be used to restrict output to variables with the spec-
ified attributes or to give variables attributes:
-a
Each name is an indexed array variable (see Section 6.7 [Arrays],
page 91).
-A
Each name is an associative array variable (see Section 6.7 [Arrays],
page 91).
-f
Use function names only.
-i
The variable is to be treated as an integer; arithmetic evaluation
(see Section 6.5 [Shell Arithmetic], page 89) is performed when the
variable is assigned a value.
-l
When the variable is assigned a value, all upper-case characters are
converted to lower-case. The upper-case attribute is disabled.
-n
Give each name the nameref attribute, making it a name reference
to another variable. That other variable is defined by the value of
name. All references, assignments, and attribute modifications to
name, except for those using or changing the -n attribute itself, are
performed on the variable referenced by name’s value. The nameref
attribute cannot be applied to array variables.
-r
Make names readonly. These names cannot then be assigned values
by subsequent assignment statements or unset.
-t
Give each name the trace attribute. Traced functions inherit the
DEBUG and RETURN traps from the calling shell. The trace attribute
has no special meaning for variables.
-u
When the variable is assigned a value, all lower-case characters are
converted to upper-case. The lower-case attribute is disabled.
-x
Mark each name for export to subsequent commands via the envi-
ronment.
Using ‘+’ instead of ‘-’ turns off the attribute instead, with the exceptions that
‘+a’ may not be used to destroy an array variable and ‘+r’ will not remove the
readonly attribute. When used in a function, declare makes each name local,
as with the local command, unless the -g option is used. If a variable name
is followed by =value, the value of the variable is set to value.
When using -a or -A and the compound assignment syntax to create array
variables, additional attributes do not take effect until subsequent assignments.
The return status is zero unless an invalid option is encountered, an attempt
is made to define a function using ‘-f foo=bar’, an attempt is made to assign


Chapter 4: Shell Builtin Commands
53
a value to a readonly variable, an attempt is made to assign a value to an
array variable without using the compound assignment syntax (see Section 6.7
[Arrays], page 91), one of the names is not a valid shell variable name, an
attempt is made to turn off readonly status for a readonly variable, an attempt
is made to turn off array status for an array variable, or an attempt is made to
display a non-existent function with -f.
echo
echo [-neE] [arg ...]
Output the args, separated by spaces, terminated with a newline. The return
status is 0 unless a write error occurs. 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.
The xpg_echo shell option may be used to dynamically determine whether or
not echo expands these escape characters by default. echo does not interpret
-- to mean the end of options.
echo interprets the following escape sequences:
\a
alert (bell)
\b
backspace
\c
suppress further output
\e
\E
escape
\f
form feed
\n
new line
\r
carriage return
\t
horizontal tab
\v
vertical tab
\\
backslash
\0nnn
the eight-bit character whose value is the octal value nnn (zero to
three octal digits)
\xHH
the eight-bit character whose value is the hexadecimal value HH
(one or two hex digits)
\uHHHH
the Unicode (ISO/IEC 10646) character whose value is the hex-
adecimal value HHHH (one to four hex digits)
\UHHHHHHHH
the Unicode (ISO/IEC 10646) character whose value is the hex-
adecimal value HHHHHHHH (one to eight hex digits)
enable
enable [-a] [-dnps] [-f filename] [name ...]


Chapter 4: Shell Builtin Commands
54
Enable and disable builtin shell commands. Disabling a builtin allows a disk
command which has the same name as a shell builtin to be executed without
specifying a full pathname, even though the shell normally searches for builtins
before disk commands. If -n is used, the names become disabled. Otherwise
names are enabled.
For example, to use the test binary found via $PATH
instead of the shell builtin version, type ‘enable -n test’.
If the -p option is supplied, or no name arguments appear, a list of shell
builtins is printed. With no other arguments, the list consists of all enabled
shell builtins. The -a option means to list each builtin with an indication of
whether or not it is enabled.
The -f option means to load the new builtin command name from shared object
filename, on systems that support dynamic loading. The -d option will delete
a builtin loaded with -f.
If there are no options, a list of the shell builtins is displayed. The -s option
restricts enable to the posix special builtins. If -s is used with -f, the new
builtin becomes a special builtin (see Section 4.4 [Special Builtins], page 70).
The return status is zero unless a name is not a shell builtin or there is an error
loading a new builtin from a shared object.
help
help [-dms] [pattern]
Display helpful information about builtin commands. If pattern is specified,
help gives detailed help on all commands matching pattern, otherwise a list of
the builtins is printed.
Options, if supplied, have the following meanings:
-d
Display a short description of each pattern
-m
Display the description of each pattern in a manpage-like format
-s
Display only a short usage synopsis for each pattern
The return status is zero unless no command matches pattern.
let
let expression [expression ...]
The let builtin allows arithmetic to be performed on shell variables. Each
expression is evaluated according to the rules given below in Section 6.5 [Shell
Arithmetic], page 89.
If the last expression evaluates to 0, let returns 1;
otherwise 0 is returned.
local
local [option] name[=value] ...
For each argument, a local variable named name is created, and assigned value.
The option can be any of the options accepted by declare. local can only
be used within a function; it makes the variable name have a visible scope
restricted to that function and its children. If name is ‘-’, the set of shell
options is made local to the function in which local is invoked: shell options


Yüklə 4,8 Kb.

Dostları ilə paylaş:
1   ...   18   19   20   21   22   23   24   25   ...   66




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©genderi.org 2024
rəhbərliyinə müraciət

    Ana səhifə