diff --git a/bash-5.1/builtins_rust/common/Cargo.toml b/bash-5.1/builtins_rust/common/Cargo.toml index a180848df16c907213f174d8b8b639b659d44cc3..374f067fa7a3dbe1753af1cb1e9385a325fa611b 100644 --- a/bash-5.1/builtins_rust/common/Cargo.toml +++ b/bash-5.1/builtins_rust/common/Cargo.toml @@ -8,8 +8,7 @@ edition = "2021" [dependencies] libc = "0.2" nix = "0.24" - - +unic-langid = "0.9.0" [lib] crate-type = ["staticlib","rlib"] name = "rcommon" diff --git a/bash-5.1/builtins_rust/common/src/lib.rs b/bash-5.1/builtins_rust/common/src/lib.rs index e01b6705d7f32b1349e8c6457e1130d6bddffe63..1e48063864edccc01012cb39dad7d68d6d0b07e6 100644 --- a/bash-5.1/builtins_rust/common/src/lib.rs +++ b/bash-5.1/builtins_rust/common/src/lib.rs @@ -6,7 +6,8 @@ use std::ffi::{CStr, CString}; use std::mem::size_of; use std::ptr::read_volatile; use nix::errno::errno; - +use std::env::var; +use unic_langid::LanguageIdentifier; include!(concat!("lib_readline_keymaps.rs")); include!(concat!("command.rs")); @@ -662,6 +663,7 @@ extern "C"{ fn builtin_help(); fn builtin_error(format:*const c_char,...); + } unsafe fn ISOPTION(s:* const c_char, c:c_char)->bool @@ -1730,7 +1732,7 @@ pub extern "C" fn r_builtin_bind_variable(name:*mut c_char,value:*mut c_char,fla /* Like check_unbind_variable, but for use by builtins (only matters for error messages). */ -pub extern "C" fn r_builtin_unbind_variable(vname:*const c_char)->i32{ + pub extern "C" fn r_builtin_unbind_variable(vname:*const c_char)->i32{ let v:*mut SHELL_VAR; unsafe{ @@ -1753,3 +1755,20 @@ pub extern "C" fn r_builtin_unbind_variable(vname:*const c_char)->i32{ } } +pub extern "C" fn get_local_str()-> Vec{ + + let lang : String; + match var("LANGUAGE") { + Ok(v) => lang = v , + Err(e) => + { + lang = String::from("en-US"); + println!("err is {e:?}") + }, + } + println!("now language is {:?}",lang); + //parse() 用于类型转换 + let langid : LanguageIdentifier = lang.parse().expect("wrong language"); + let locales = vec![langid.into()]; + return locales; + } \ No newline at end of file diff --git a/bash-5.1/builtins_rust/help/Cargo.toml b/bash-5.1/builtins_rust/help/Cargo.toml index 993d13e0d1533cd1e18757cb8589fb5f3952316e..1228246909ca100596ed04a5dc39014978b8690a 100644 --- a/bash-5.1/builtins_rust/help/Cargo.toml +++ b/bash-5.1/builtins_rust/help/Cargo.toml @@ -9,6 +9,9 @@ edition = "2018" libc = "0.2" nix = "0.24.1" rcommon = {path ="../common"} +fluent = "0.16.0" +fluent-bundle = "0.15.2" +fluent-resmgr = "0.0.5" [lib] crate-type = ["staticlib","rlib"] diff --git a/bash-5.1/builtins_rust/help/src/lib.rs b/bash-5.1/builtins_rust/help/src/lib.rs index 37ce387c6d3b529b16fb160e8fbc9f0056bfa39d..7e51d7da6ad69f8ceade35646d98f691e3ab18a6 100644 --- a/bash-5.1/builtins_rust/help/src/lib.rs +++ b/bash-5.1/builtins_rust/help/src/lib.rs @@ -3,8 +3,12 @@ extern crate nix; extern crate std; use libc::{c_char, c_void ,putchar, free}; use std::{ffi::{CString,CStr}, i32, io::{Read, stdout, Write}, mem, string, u32}; -use rcommon::{WordList, WordDesc, EX_USAGE, EXECUTION_SUCCESS, EXECUTION_FAILURE, EX_NOTFOUND, EX_NOEXEC, SUBSHELL_PAREN,r_builtin_usage}; +use rcommon::{WordList, WordDesc, EX_USAGE, EXECUTION_SUCCESS, + EXECUTION_FAILURE, EX_NOTFOUND, EX_NOEXEC, SUBSHELL_PAREN, + r_builtin_usage,get_local_str}; +use fluent_bundle::{FluentBundle, FluentResource, FluentValue, FluentArgs}; +use fluent_resmgr::resource_manager::ResourceManager; pub enum Option { None, Some(T), @@ -421,10 +425,12 @@ fn show_manpage (name : *mut c_char, i : i32){ let mut j :i32; let mut doc :*mut *mut libc::c_char; - let mut line :*mut libc::c_char = 0 as *mut libc::c_char;; + let mut line :*mut libc::c_char = 0 as *mut libc::c_char; let mut fd: i32; let mut usefile : bool; let builtin1 = unsafe{&(*((shell_builtins as usize + (i*BUILTIN_SIZEOF!()) as usize) as *mut builtin))}; + let mgr = ResourceManager::new("./resources/{locale}/{res_id}".into()); + let resources = vec![ "message.ftl".into()]; unsafe { doc = builtin1.long_doc; @@ -448,7 +454,6 @@ fn show_manpage (name : *mut c_char, i : i32){ } } else { - if doc!= std::ptr::null_mut(){ unsafe { line = *doc as *mut libc::c_char; @@ -460,9 +465,16 @@ fn show_manpage (name : *mut c_char, i : i32){ } /* NAME */ println! ("NAME\n"); - unsafe { - println! (" - {:?} ", CStr::from_ptr(name)); - } + let mut args = FluentArgs::new(); + let c_str: &CStr = unsafe { CStr::from_ptr(builtin1.name) }; + let msg: &str = c_str.to_str().unwrap(); + args.set("cmdName",msg); + let bundle = mgr.get_bundle(get_local_str(), resources); + let mut value = bundle.get_message("helpname").unwrap(); + let mut pattern = value.value().expect("partern err"); + let mut errors = vec![]; + let mut msg1 = bundle.format_pattern(&pattern, Some(&args), &mut errors); + println!("{}", msg1); let mut j = 0 ; unsafe { while (*((doc as usize + (8*j))as *mut *mut c_char)as *mut c_char) != std::ptr::null_mut() { @@ -484,13 +496,10 @@ fn show_manpage (name : *mut c_char, i : i32){ /* DESCRIPTION */ println! ("DESCRIPTION\n"); if !usefile{ - let mut j = 0 ; - unsafe { - while (*((doc as usize + (8*j))as *mut *mut c_char)as *mut c_char) != std::ptr::null_mut() { - println! (" {:?}\n", unsafe{CStr::from_ptr(*((doc as usize + (8*j))as *mut *mut c_char)as *mut c_char)}); - j += 1; - } - } + value = bundle.get_message("helplongdoc").unwrap(); + pattern = value.value().expect("partern err"); + msg1 = bundle.format_pattern(&pattern, Some(&args), &mut errors); + println!("{}", msg1); } else{ while doc != std::ptr::null_mut() && (((doc as usize + (8*j)))as * mut c_char) != std::ptr::null_mut() { @@ -665,3 +674,4 @@ unsafe { // } // len // } + diff --git a/bash-5.1/resources/en-US/message.ftl b/bash-5.1/resources/en-US/message.ftl new file mode 100644 index 0000000000000000000000000000000000000000..64091a658ba38a9a0daa59ae5a6cf9816515f7a7 --- /dev/null +++ b/bash-5.1/resources/en-US/message.ftl @@ -0,0 +1,1494 @@ +helplongdoc ={ +$cmdName -> + [set] + Set or unset values of shell options and positional parameters. + + Change the value of shell attributes and positional parameters, or + display tmes and values of shell variables. + + Options: + -a Mark variables which are modified or created for export. + -b Notify of job termination immediately. + -e Exit immediately if a command exits with a non-zero status. + -f Disable file name generation (globbing). + -h Remember the location of commands as they are looked up. + -k All assignment arguments are placed in the environment for a + command, not just those that precede the command name. + -m Job control is enabled. + -n Read commands but do not execute them. + -o option-name + Set the variable corresponding to option-name: + allexport same as -a + braceexpand same as -B + emacs use an emacs-style line editing interface + errexit same as -e + errtrace same as -E + functrace same as -T + hashall same as -h + histexpand same as -H + history enable command history + ignoreeof the shell will not exit upon reading EOF + interactive-comments + allow comments to appear in interactive commands + keyword same as -k + monitor same as -m + noclobber same as -C + noexec same as -n + noglob same as -f + nolog currently accepted but ignored + notify same as -b + nounset same as -u + onecmd same as -t + physical same as -P + pipefail the return value of a pipeline is the status of + the last command to exit with a non-zero status, + or zero if no command exited with a non-zero status + posix change the behavior of bash where the default + operation differs from the Posix standard to + match the standard + privileged same as -p + verbose same as -v + vi use a vi-style line editing interface + xtrace same as -x + -p Turned on whenever the real and effective user ids do not match. + Disables processing of the $ENV file and importing of shell + functions. Turning this option off causes the effective uid and + gid to be set to the real uid and gid. + -t Exit after reading and executing one command. + -u Treat unset variables as an error when substituting. + -v Print shell input lines as they are read. + -x Print commands and their arguments as they are executed. + -B the shell will perform brace expansion + -C If set, disallow existing regular files to be overwritten + by redirection of output. + -E If set, the ERR trap is inherited by shell functions. + -H Enable ! style history substitution. This flag is on + by default when the shell is interactive. + -P If set, do not resolve symbolic links when executing commands + such as cd which change the current directory. + -T If set, the DEBUG and RETURN traps are inherited by shell functions. + -- Assign any remaining arguments to the positional parameters. + If there are no remaining arguments, the positional parameters + are unset. + - Assign any remaining arguments to the positional parameters. + The -x and -v options are turned off. + + Using + rather than - causes these flags to be turned off. + The flags can also be used upon invocation of the shell. + The current set of flags may be found in $-. + The remaining n ARGs are positional + parameters and are assigned, in order, to $1, $2, .. $n. If no + ARGs are given, all shell variables are printed. + + Exit Status: + Returns success unless an invalid option is given. + [read] Read a line from the standard input and split it into fields. + + Reads a single line from the standard input, or from file descriptor FD + if the -u option is supplied. The line is split into fields as with + word splitting, and the first word is assigned to the first NAME, the + second word to the second NAME, and so on, with any leftover words + assigned to the last NAME. Only the characters found in $IFS are recognized + as word delimiters. + + If no NAMEs are supplied, the line read is stored in the REPLY + variable. + + Options: + -a array assign the words read to sequential indices of the array + variable ARRAY, starting at zero + -d delim continue until the first character of DELIM is read, rather + than newline + -e use Readline to obtain the line + -i text use TEXT as the initial text for Readline + -n nchars return after reading NCHARS characters rather than waiting + for a newline, but honor a delimiter if fewer than + NCHARS characters are read before the delimiter + -N nchars return only after reading exactly NCHARS characters, + unless + EOF is encountered or read times out, ignoring any + delimiter + -p prompt output the string PROMPT without a trailing newline before + attempting to read + -r do not allow backslashes to escape any characters + -s do not echo input coming from a terminal + -t timeout time out and return failure if a complete line of + input is not read within TIMEOUT seconds. The value of the + TMOUT variable is the default timeout. TIMEOUT may be a + fractional number. If TIMEOUT is 0, read returns + immediately, without trying to read any data, returning + success only if input is available on the specified + file descriptor. The exit status is greater than 128 + if the timeout is exceeded + -u fd read from file descriptor FD instead of the standard input + + Exit Status: + The return code is zero, unless end-of-file is encountered, read times + out (in which case it's greater than 128), a variable assignment error + occurs, or an invalid file descriptor is supplied as the argument to -u. + + [type] Display information about command type. + + For each NAME, indicate how it would be interpreted if used as a + command name. + + Options: + -a display all locations containing an executable named NAME; + includes aliases, builtins, and functions, if and only if + the `-p' option is not also used + -f suppress shell function lookup + -P force a PATH search for each NAME, even if it is an alias, + builtin, or function, and returns the name of the disk file + that would be executed + -p returns either the name of the disk file that would be executed, + or nothing if `type -t NAME' would not return `file' + -t output a single word which is one of `alias', `keyword', + `function', `builtin', `file' or `', if NAME is an alias, + shell reserved word, shell function, shell builtin, disk file, + or not found, respectively + + Arguments: + NAME Command name to be interpreted. + + Exit Status: + Returns success if all of the NAMEs are found; fails if any are not + found. + + [trap] Trap signals and other events. + + Defines and activates handlers to be run when the shell receives + signals or other conditions. + + ARG is a command to be read and executed when the shell receives the + signal(s) SIGNAL_SPEC. If ARG is absent (and a single SIGNAL_SPEC + is supplied) or `-', each specified signal is reset to its original + value. If ARG is the null string each SIGNAL_SPEC is ignored by the + shell and by the commands it invokes. + + If a SIGNAL_SPEC is EXIT (0) ARG is executed on exit from the shell. + If a SIGNAL_SPEC is DEBUG, ARG is executed before every simple command. + If a SIGNAL_SPEC is RETURN, ARG is executed each time a shell function or + a script run by the . or source builtins finishes executing. A + SIGNAL_SPEC of ERR means to execute ARG each time a command's failure + would cause the shell to exit when the -e option is enabled. + + If no arguments are supplied, trap prints the list of commands + associated with each signal. + + Options: + -l print a list of signal names and their corresponding numbers + -p display the trap commands associated with each SIGNAL_SPEC + + Each SIGNAL_SPEC is either a signal name in or a signal + number. + Signal names are case insensitive and the SIG prefix is optional. A + signal may be sent to the shell with \kill -signal $$\. + + Exit Status: + Returns success unless a SIGSPEC is invalid or an invalid option is + given. + + [alias] Define or display aliases. + + Without arguments, `alias' prints the list of aliases in the reusable + form `alias NAME=VALUE' on standard output. + + Otherwise, 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. + + Options: + -p print all defined aliases in a reusable format + + Exit Status: + alias returns true unless a NAME is supplied for which no alias has + been defined. + + [unalias] Remove each NAME from the list of defined aliases. + + Options: + -a remove all alias definitions + + Return success unless a NAME is not an existing alias. + + [break] Exit for, while, or until loops. + + Exit a FOR, WHILE or UNTIL loop. If N is specified, break N enclosing + loops. + + Exit Status: + The exit status is 0 unless N is not greater than or equal to 1. + + [continue] Resume for, while, or until loops. + + Resumes the next iteration of the enclosing FOR, WHILE or UNTIL loop. + If N is specified, resumes the Nth enclosing loop. + + Exit Status: + The exit status is 0 unless N is not greater than or equal to 1. + + [builtin] Execute shell builtins. + + Execute SHELL-BUILTIN with arguments ARGs without performing command + lookup. This is useful when you wish to reimplement a shell builtin + as a shell function, but need to execute the builtin within the + function. + + Exit Status: + Returns the exit status of SHELL-BUILTIN, or false if SHELL-BUILTIN is + not a shell builtin. + + [caller] Returns the context of the current subroutine call. + + Without EXPR, returns \$line $filename\. With EXPR, returns + \$line $subroutine $filename\; this extra information can be used to + provide a stack trace. + + The value of EXPR indicates how many call frames to go back before the + current one; the top frame is frame 0. + + [cd] Change the shell working directory. + + Change the current directory to DIR. The default DIR is the value of + the HOME shell variable. + + The variable CDPATH defines the search path for the directory + containing DIR. Alternative directory names in CDPATH are + separated by a colon (:). + A null directory name is the same as the current directory. If DIR + begins with a slash (/), then CDPATH is not used. + + If the directory is not found, and the shell option `cdable_vars' is + set,the word is assumed to be a variable name. If that variable has a + value,its value is used for DIR. + + Options: + -L force symbolic links to be followed: resolve symbolic + links in DIR after processing instances of `..' + -P use the physical directory structure without following + symbolic links: resolve symbolic links in DIR before + processing instances of `..' + -e if the -P option is supplied, and the current working + directory cannot be determined successfully, exit with + a non-zero status + -@ on systems that support it, present a file with extended + attributes as a directory containing the file attributes + + The default is to follow symbolic links, as if `-L' were specified. + `..' is processed by removing the immediately previous pathname + component back to a slash or the beginning of DIR. + + Exit Status: + Returns 0 if the directory is changed, and if $PWD is set successfully + when -P is used; non-zero otherwise. + + [pwd] Print the name of the current working directory. + + Options: + -L print the value of $PWD if it names the current working + directory + -P print the physical directory, without any symbolic links + + By default, `pwd' behaves as if `-L' were specified. + + Exit Status: + Returns 0 unless an invalid option is given or the current directory + cannot be read. + + [true] Null command. + + No effect; the command does nothing. + + Exit Status: + Always succeeds. + + [shopt] Set and unset shell options. + + Change the setting of each shell option OPTNAME. Without any option + arguments, list each supplied OPTNAME, or all shell options if no + OPTNAMEs are given, with an indication of whether or not each is set. + + Options: + -o restrict OPTNAMEs to those defined for use with `set -o' + -p print each shell option with an indication of its status + -q suppress output + -s enable (set) each OPTNAME + -u disable (unset) each OPTNAME + + Exit Status: + Returns success if OPTNAME is enabled; fails if an invalid option is + given or OPTNAME is disabled. + + [false] Return an unsuccessful result. + + Exit Status: + Always fails. + + [command] Execute a simple command or display information about commands. + + Runs COMMAND with ARGS suppressing shell function lookup, or display + information about the specified COMMANDs. Can be used to invoke + commands on disk when a function with the same name exists. + + Options: + -p use a default value for PATH that is guaranteed to find all of + the standard utilities + -v print a description of COMMAND similar to the `type' builtin + -V print a more verbose description of each COMMAND + + Exit Status: + Returns exit status of COMMAND, or failure if COMMAND is not found. + + [echo] Write arguments to the standard output. + + Display the ARGs, separated by a single space character and followed by + a newline, on the standard output. + + Options: + -n do not append a newline + -e enable interpretation of the following backslash escapes + -E explicitly suppress interpretation of backslash escapes + + `echo' interprets the following backslash-escaped characters: + \\a alert (bell) + \\b backspace + \\c suppress further output + \\e escape character + \\E escape character + \\f form feed + \ new line + \\r carriage return + \ horizontal tab + \\v vertical tab + \\\\ backslash + \\0nnn the character whose ASCII code is NNN (octal). NNN can be + 0 to 3 octal digits + \\xHH the eight-bit character whose value is HH (hexadecimal). HH + can be one or two hex digits + \\uHHHH the Unicode character whose value is the hexadecimal value + HHHH. + HHHH can be one to four hex digits. + \\UHHHHHHHH the Unicode character whose value is the hexadecimal + value + HHHHHHHH. HHHHHHHH can be one to eight hex digits. + + Exit Status: + Returns success unless a write error occurs. + + [enable] Enable and disable shell builtins. + + Enables and disables builtin shell commands. Disabling allows you to + execute a disk command which has the same name as a shell builtin + without using a full pathname. + + Options: + -a print a list of builtins showing whether or not each is enabled + -n disable each NAME or display a list of disabled builtins + -p print the list of builtins in a reusable format + -s print only the names of Posix `special' builtins + + Options controlling dynamic loading: + -f Load builtin NAME from shared object FILENAME + -d Remove a builtin loaded with -f + + Without options, each NAME is enabled. + + To use the `test' found in $PATH instead of the shell builtin + version, type `enable -n test'. + + Exit Status: + Returns success unless NAME is not a shell builtin or an error occurs. + + [getopts] Parse option arguments. + + Getopts is used by shell procedures to parse positional parameters + as options. + + OPTSTRING contains the option letters to be recognized; if a letter + is followed by a colon, the option is expected to have an argument, + which should be separated from it by white space. + + Each time it is invoked, getopts will place the next option in the + shell variable $name, initializing name if it does not exist, and + the index of the next argument to be processed into the shell + variable OPTIND. OPTIND is initialized to 1 each time the shell or + a shell script is invoked. When an option requires an argument, + getopts places that argument into the shell variable OPTARG. + + getopts reports errors in one of two ways. If the first character + of OPTSTRING is a colon, getopts uses silent error reporting. In + this mode, no error messages are printed. If an invalid option is + seen, getopts places the option character found into OPTARG. If a + required argument is not found, getopts places a ':' into NAME and + sets OPTARG to the option character found. If getopts is not in + silent mode, and an invalid option is seen, getopts places '?' into + NAME and unsets OPTARG. If a required argument is not found, a '?' + is placed in NAME, OPTARG is unset, and a diagnostic message is + printed. + + If the shell variable OPTERR has the value 0, getopts disables the + printing of error messages, even if the first character of + OPTSTRING is not a colon. OPTERR has the value 1 by default. + + Getopts normally parses the positional parameters, but if arguments + are supplied as ARG values, they are parsed instead. + + Exit Status: + Returns success if an option is found; fails if the end of options is + encountered or an error occurs. + + [exec] Replace the shell with the given command. + + Execute COMMAND, replacing this shell with the specified program. + ARGUMENTS become the arguments to COMMAND. If COMMAND is not + specified, + any redirections take effect in the current shell. + + Options: + -a name pass NAME as the zeroth argument to COMMAND + -c execute COMMAND with an empty environment + -l place a dash in the zeroth argument to COMMAND + + If the command cannot be executed, a non-interactive shell exits, + unless + the shell option `execfail' is set. + + Exit Status: + Returns success unless COMMAND is not found or a redirection error + occurs. + + [exit] Exit the shell. + + Exits the shell with a status of N. If N is omitted, the exit status + is that of the last command executed. + + [logout] Exit a login shell. + + Exits a login shell with exit status N. Returns an error if not + executed in a login shell. + + [fc] Display or execute commands from the history list. + + fc is used to list or edit and re-execute commands from the history + list. + FIRST and LAST can be numbers specifying the range, or FIRST can be a + string, which means the most recent command beginning with that + string. + + Options: + -e ENAME select which editor to use. Default is FCEDIT, then + EDITOR, + then vi + -l list lines instead of editing + -n omit line numbers when listing + -r reverse the order of the lines (newest listed first) + + With the `fc -s [pat=rep ...] [command]' format, COMMAND is + re-executed after the substitution OLD=NEW is performed. + + 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. + + Exit Status: + Returns success or status of executed command; non-zero if an error + occurs. + + [fg] Resume job in foreground. + + Equivalent to the JOB_SPEC argument to the `fg' command. Resume a + stopped or background job. JOB_SPEC can specify either a job name + or a job number. Following JOB_SPEC with a `&' places the job in + the background, as if the job specification had been supplied as an + argument to `bg'. + + Exit Status: + Returns the status of the resumed job. + + [bg] Move jobs to the background. + + Place the jobs identified by each JOB_SPEC in the background, as if + they had been started with `&'. If JOB_SPEC is not present, the shell's + notion of the current job is used. + + Exit Status: + Returns success unless job control is not enabled or an error occurs. + + [hash] Remember or display program locations. + + Determine and remember the full pathname of each command NAME. If + no arguments are given, information about remembered commands is + displayed. + + Options: + -d forget the remembered location of each NAME + -l display in a format that may be reused as input + -p pathname use PATHNAME as the full pathname of NAME + -r forget all remembered locations + -t print the remembered location of each NAME, preceding + each location with the corresponding NAME if multiple + NAMEs are given + Arguments: + NAME Each NAME is searched for in $PATH and added to the list + of remembered commands. + + + [help] Display information about builtin commands. + + Displays brief summaries of builtin commands. If PATTERN is + specified, gives detailed help on all commands matching PATTERN, + otherwise the list of help topics is printed. + + Options: + -d output short description for each topic + -m display usage in pseudo-manpage format + -s output only a short usage synopsis for each topic matching + PATTERN + + Arguments: + PATTERN Pattern specifying a help topic + + Exit Status: + Returns success unless PATTERN is not found or an invalid option is + given. + + [history] Display or manipulate the history list. + + Display the history list with line numbers, prefixing each modified + entry with a `*'. An argument of N lists only the last N entries. + + Options: + -c clear the history list by deleting all of the entries + -d offset delete the history entry at position OFFSET. Negative + offsets count back from the end of the history list + + -a append history lines from this session to the history file + -n read all history lines not already read from the history file + and append them to the history list + -r read the history file and append the contents to the history + list + -w write the current history to the history file + + -p perform history expansion on each ARG and display the result + without storing it in the history list + -s append the ARGs to the history list as a single entry + + If FILENAME is given, it is used as the history file. Otherwise, + if HISTFILE has a value, that is used, else ~/.bash_history. + + If the HISTTIMEFORMAT variable is set and not null, its value is used + as a format string for strftime(3) to print the time stamp associated + with each displayed history entry. No time stamps are printed + otherwise. + + Exit Status: + Returns success unless an invalid option is given or an error occurs. + + [jobs] Display status of jobs. + + Lists the active jobs. JOBSPEC restricts output to that job. + Without options, the status of all active jobs is displayed. + + Options: + -l lists process IDs in addition to the normal information + -n lists only processes that have changed status since the last + notification + -p lists process IDs only + -r restrict output to running jobs + -s restrict output to stopped jobs + + If -x is supplied, COMMAND is run after all job specifications that + appear in ARGS have been replaced with the process ID of that job's + process group leader. + + Exit Status: + Returns success unless an invalid option is given or an error occurs. + If -x is used, returns the exit status of COMMAND. + + [disown] Remove jobs from current shell. + + Removes each JOBSPEC argument from the table of active jobs. Without + any JOBSPECs, the shell uses its notion of the current job. + + Options: + -a remove all jobs if JOBSPEC is not supplied + -h mark each JOBSPEC so that SIGHUP is not sent to the job if the + shell receives a SIGHUP + -r remove only running jobs + + Exit Status: + Returns success unless an invalid option or JOBSPEC is given. + + [kill] Send a signal to a job. + + Send the processes identified by PID or JOBSPEC the signal named by + SIGSPEC or SIGNUM. If neither SIGSPEC nor SIGNUM is present, then + SIGTERM is assumed. + + Options: + -s sig SIG is a signal name + -n sig SIG is a signal number + -l list the signal names; if arguments follow `-l' they are + assumed to be signal numbers for which names should be listed + -L synonym for -l + + Kill is a shell builtin for two reasons: it allows job IDs to be used + instead of process IDs, and allows processes to be killed if the limit + on processes that you can create is reached. + + Exit Status: + Returns success unless an invalid option is given or an error occurs. + + [let] Evaluate arithmetic expressions. + + Evaluate each ARG as an arithmetic expression. Evaluation is done in + fixed-width 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. + + id++, id-- variable post-increment, post-decrement + ++id, --id variable pre-increment, pre-decrement + -, + unary minus, plus + !, ~ logical and bitwise negation + ** exponentiation + *, /, % multiplication, division, remainder + +, - addition, subtraction + <<, >> left and right bitwise shifts + <=, >=, <, > comparison + ==, != equality, inequality + & bitwise AND + ^ bitwise XOR + | bitwise OR + && logical AND + || logical OR + expr ? expr : expr + conditional operator + =, *=, /=, %=, + +=, -=, <<=, >>=, + &=, ^=, |= assignment + + Shell variables are allowed as operands. The name of the variable + is replaced by its value (coerced to a fixed-width integer) within + an expression. The variable need not have its integer attribute + turned on to be used in an expression. + + Operators are evaluated in order of precedence. Sub-expressions in + parentheses are evaluated first and may override the precedence + rules above. + + Exit Status: + If the last ARG evaluates to 0, let returns 1; let returns 0 otherwise. + + [shift] Shift positional parameters. + + Rename the positional parameters $N+1,$N+2 ... to $1,$2 ... If N is + not given, it is assumed to be 1. + + Exit Status: + Returns success unless N is negative or greater than $#. + + [suspend] Suspend shell execution. + + Suspend the execution of this shell until it receives a SIGCONT signal. + Unless forced, login shells cannot be suspended. + + Options: + -f force the suspend, even if the shell is a login shell + + Exit Status: + Returns success unless job control is not enabled or an error occurs. + + [eval] Evaluate conditional expression. + + Exits with a status of 0 (true) or 1 (false) depending on + the evaluation of 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. + + The behavior of test depends on the number of arguments. Read the + bash manual page for the complete specification. + + File operators: + + -a FILE True if file exists. + -b FILE True if file is block special. + -c FILE True if file is character special. + -d FILE True if file 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 is set-group-id. + -h FILE True if file is a symbolic link. + -L FILE True if file is a symbolic link. + -k FILE True if file has its `sticky' bit set. + -p FILE True if file is a named pipe. + -r FILE True if file is readable by you. + -s FILE True if file exists and is not empty. + -S FILE True if file is a socket. + -t FD True if FD is opened on a terminal. + -u FILE True if the file is set-user-id. + -w FILE True if the file is writable by you. + -x FILE True if the file is executable by you. + -O FILE True if the file is effectively owned by you. + -G FILE True if the file is effectively owned by your group. + -N FILE True if the file has been modified since it was last + read. + + FILE1 -nt FILE2 True if file1 is newer than file2 (according to + modification date). + + FILE1 -ot FILE2 True if file1 is older than file2. + + FILE1 -ef FILE2 True if file1 is a hard link to file2. + + String operators: + + -z STRING True if string is empty. + + -n STRING + STRING True if string is not empty. + + STRING1 = STRING2 + True if the strings are equal. + STRING1 != STRING2 + True if the strings are not equal. + STRING1 < STRING2 + True if STRING1 sorts before STRING2 + lexicographically. + STRING1 > STRING2 + True if STRING1 sorts after STRING2 lexicographically. + + Other operators: + + -o OPTION True if the shell option OPTION is enabled. + -v VAR True if the shell variable VAR is set. + -R VAR True if the shell variable VAR is set and is a name + reference. + ! 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 Arithmetic tests. OP is one of -eq, -ne, + -lt, -le, -gt, or -ge. + + 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. + + Exit Status: + Returns success if EXPR evaluates to true; fails if EXPR evaluates to + false or an invalid argument is given. + + [times] Display process times. + + Prints the accumulated user and system times for the shell and all of + its child processes. + + Exit Status: + Always succeeds. + + [limit] Modify shell resource limits. + + Provides control over the resources available to the shell and + processes + it creates, on systems that allow such control. + + Options: + -S use the `soft' resource limit + -H use the `hard' resource limit + -a all current limits are reported + -b the socket buffer size + -c the maximum size of core files created + -d the maximum size of a process's data segment + -e the maximum scheduling priority (`nice') + -f the maximum size of files written by the shell and its children + -i the maximum number of pending signals + -k the maximum number of kqueues allocated for this process + -l the maximum size a process may lock into memory + -m the maximum resident set size + -n the maximum number of open file descriptors + -p the pipe buffer size + -q the maximum number of bytes in POSIX message queues + -r the maximum real-time scheduling priority + -s the maximum stack size + -t the maximum amount of cpu time in seconds + -u the maximum number of user processes + -v the size of virtual memory + -x the maximum number of file locks + -P the maximum number of pseudoterminals + -R the maximum time a real-time process can run before blocking + -T the maximum number of threads + + Not all options are available on all platforms. + + If LIMIT is given, it is the new value of the specified resource; the + special LIMIT values `soft', `hard', and `unlimited' stand for the + current soft limit, the current hard limit, and no limit, respectively. + Otherwise, the current value of the specified resource is printed. 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 increments of 512 bytes, and -u, which is an unscaled + number of processes. + + Exit Status: + Returns success unless an invalid option is supplied or an error occurs. + + [umask] Display or set file mode mask. + + Sets the user file-creation mask to MODE. If MODE is omitted, prints + the current value of the mask. + + If MODE begins with a digit, it is interpreted as an octal number; + otherwise it is a symbolic mode string like that accepted by chmod(1). + + Options: + -p if MODE is omitted, output in a form that may be reused as input + -S makes the output symbolic; otherwise an octal number is output + + Exit Status: + Returns success unless MODE is invalid or an invalid option is given. + + [return] Wait for job completion and return exit status. + + Waits for each process identified by an ID, which may be a process ID or + a job specification, and reports its termination status. If ID is not + given, waits for all currently active child processes, and the return + status is zero. If ID is a job specification, waits for all processes + in that job's pipeline. + + If the -n option is supplied, waits for a single job from the list of + IDs, + or, if no IDs are supplied, for the next job to complete and returns + its + exit status. + + If the -p option is supplied, the process or job identifier of the job + for which the exit status is returned is assigned to the variable VAR + named by the option argument. The variable will be unset initially, + before + any assignment. This is useful only when the -n option is supplied. + + If the -f option is supplied, and job control is enabled, waits for the + specified ID to terminate, instead of waiting for it to change status. + + Exit Status: + Returns the status of the last ID; fails if ID is invalid or an invalid + option is given, or if -n is supplied and the shell has no unwaited-for + children. + + [wait] Wait for process completion and return exit status. + + Waits for each process specified by a PID and reports its termination + status. + If PID is not given, waits for all currently active child processes, + and the return status is zero. PID must be a process ID. + + Exit Status: + Returns the status of the last PID; fails if PID is invalid or an + invalid + option is given. + + [for] Execute commands for each member in a list. + + The `for' loop executes a sequence of commands for each member in a + list of items. If `in WORDS ...;' is not present, then `in \$@\' is + assumed. For each element in WORDS, NAME is set to that element, and + the COMMANDS are executed. + + Exit Status: + Returns the status of the last command executed. + + [select] Select words from a list and execute commands. + + The WORDS are expanded, generating a list of words. The + set of expanded words is printed on the standard error, each + preceded by a number. If `in WORDS' is not present, `in \$@\' + is assumed. 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 NAME is set + to that word. If the line is empty, WORDS and the prompt are + redisplayed. 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. COMMANDS are executed after each selection + until a break command is executed. + + Exit Status: + Returns the status of the last command executed. + + [time] Report time consumed by pipeline's execution. + + Execute PIPELINE and print a summary of the real time, user CPU time, + and system CPU time spent executing PIPELINE when it terminates. + + Options: + -p print the timing summary in the portable Posix format + + The value of the TIMEFORMAT variable is used as the output format. + + Exit Status: + The return status is the return status of PIPELINE. + + [case] Execute commands based on pattern matching. + + Selectively execute COMMANDS based upon WORD matching PATTERN. The + `|' is used to separate multiple patterns. + + Exit Status: + Returns the status of the last command executed. + + [if] Execute commands based on conditional. + + The `if COMMANDS' list is executed. If its exit status is zero, then + the + `then COMMANDS' list is executed. Otherwise, each `elif COMMANDS' list + is + executed in turn, and if its exit status is zero, the corresponding + `then COMMANDS' list is executed and the if command completes. + Otherwise, + the `else COMMANDS' list is executed, if present. The exit status of + the + entire construct is the exit status of the last command executed, or + zero + if no condition tested true. + + Exit Status: + Returns the status of the last command executed. + + [while] Execute commands as long as a test succeeds. + + Expand and execute COMMANDS as long as the final command in the + `while' COMMANDS has an exit status of zero. + + Exit Status: + Returns the status of the last command executed. + + [until] Execute commands as long as a test does not succeed. + + Expand and execute COMMANDS as long as the final command in the + `until' COMMANDS has an exit status which is not zero. + + Exit Status: + Returns the status of the last command executed. + + [coproc] Create a coprocess named NAME. + + Execute COMMAND asynchronously, with the standard output and standard + input of the command connected via a pipe to file descriptors assigned + to indices 0 and 1 of an array variable NAME in the executing shell. + The default NAME is \COPROC\. + + Exit Status: + The coproc command returns an exit status of 0. + + [function] Define shell function. + + Create a shell function named NAME. When invoked as a simple command, + NAME runs COMMANDs in the calling shell's context. When NAME is + invoked, + the arguments are passed to the function as $1...$n, and the function's + name is in $FUNCNAME. + + Exit Status: + Returns success unless NAME is readonly. + + [variables] Common shell variable names and usage. + + BASH_VERSION Version information for this Bash. + CDPATH A colon-separated list of directories to search + for directories given as arguments to `cd'. + GLOBIGNORE A colon-separated list of patterns describing filenames to + be ignored by pathname expansion. + HISTFILE The name of the file where your command history is stored. + HISTFILESIZE The maximum number of lines this file can contain. + HISTSIZE The maximum number of history lines that a running + shell can access. + HOME The complete pathname to your login directory. + HOSTNAME The name of the current host. + HOSTTYPE The type of CPU this version of Bash is running under. + IGNOREEOF Controls the action of the shell on receipt of an EOF + character as the sole input. If set, then the value + of it is the number of EOF characters that can be seen + in a row on an empty line before the shell will exit + (default 10). When unset, EOF signifies the end of input. + MACHTYPE A string describing the current system Bash is running on. + MAILCHECK How often, in seconds, Bash checks for new mail. + MAILPATH A colon-separated list of filenames which Bash checks + for new mail. + OSTYPE The version of Unix this version of Bash is running on. + PATH A colon-separated list of directories to search when + looking for commands. + PROMPT_COMMAND A command to be executed before the printing of each + primary prompt. + PS1 The primary prompt string. + PS2 The secondary prompt string. + PWD The full pathname of the current directory. + SHELLOPTS A colon-separated list of enabled shell options. + TERM The name of the current terminal type. + TIMEFORMAT The output format for timing statistics displayed by the + `time' reserved word. + auto_resume Non-null means a command word appearing on a line by + itself is first looked for in the list of currently + stopped jobs. If found there, that job is foregrounded. + A value of `exact' means that the command word must + exactly match a command in the list of stopped jobs. A + value of `substring' means that the command word must + match a substring of the job. Any other value means that + the command must be a prefix of a stopped job. + histchars Characters controlling history expansion and quick + substitution. The first character is the history + substitution character, usually `!'. The second is + the `quick substitution' character, usually `^'. The + third is the `history comment' character, usually `#'. + HISTIGNORE A colon-separated list of patterns used to decide which + commands should be saved on the history list. + + [pushd] Add directories to stack. + + Adds a directory to the top of the directory stack, or rotates + the stack, making the new top of the stack the current working + directory. With no arguments, exchanges the top two directories. + + Options: + -n Suppresses the normal change of directory when adding + directories to the stack, so only the stack is manipulated. + + Arguments: + +N Rotates the stack so that the Nth directory (counting + from the left of the list shown by `dirs', starting with + zero) is at the top. + + -N Rotates the stack so that the Nth directory (counting + from the right of the list shown by `dirs', starting with + zero) is at the top. + + dir Adds DIR to the directory stack at the top, making it the + new current working directory. + + The `dirs' builtin displays the directory stack. + + Exit Status: + Returns success unless an invalid argument is supplied or the directory + change fails. + + [popd] Removes entries from the directory stack. With no arguments, removes + the top directory from the stack, and changes to the new top directory. + + Options: + -n Suppresses the normal change of directory when removing + directories from the stack, so only the stack is manipulated. + + Arguments: + +N Removes the Nth entry counting from the left of the list + shown by `dirs', starting with zero. For example: `popd +0' + removes the first directory, `popd +1' the second. + + -N Removes the Nth entry counting from the right of the list + shown by `dirs', starting with zero. For example: `popd -0' + removes the last directory, `popd -1' the next to last. + + The `dirs' builtin displays the directory stack. + the stack, making the new top of the stack the current working + directory. With no arguments, exchanges the top two directories. + + [dirs] Display the list of currently remembered directories. Directories + find their way onto the list with the `pushd' command; you can get + back up through the list with the `popd' command. + + Options: + -c clear the directory stack by deleting all of the elements + -l do not print tilde-prefixed versions of directories relative + to your home directory + -p print the directory stack with one entry per line + -v print the directory stack with one entry per line prefixed + with its position in the stack + + Arguments: + +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. + + + [printf] Formats and prints ARGUMENTS under control of the FORMAT. + + Options: + -v var assign the output to shell variable VAR rather than + display it on the standard output + + FORMAT is a character string which contains three types of objects: + plain + characters, which are simply copied to standard output; character + escape + sequences, which are converted and copied to the standard output; and + format specifications, each of which causes printing of the next + successive + argument. + + In addition to the standard format specifications described in + printf(1), + printf interprets: + + %b expand backslash escape sequences in the corresponding argument + %q quote the argument in a way that can be reused as shell input + %(fmt)T output the date-time string resulting from using FMT as a + format + string for strftime(3) + + The format is re-used as necessary to consume all of the arguments. If + there are fewer arguments than the format requires, extra format + specifications behave as if a zero value or null string, as + appropriate, + had been supplied. + + Exit Status: + Returns success unless an invalid option is given or a write or + assignment + error occurs. + + [complete] Specify how arguments are to be completed by Readline. + + For each NAME, specify how arguments are to be completed. If no + options are supplied, existing completion specifications are printed + in a way that allows them to be reused as input. + + Options: + -p print existing completion specifications in a reusable format + -r remove a completion specification for each NAME, or, if no + NAMEs are supplied, all completion specifications + -D apply the completions and actions as the default for commands + without any specific completion defined + -E apply the completions and actions to \empty\ commands -- + completion attempted on a blank line + -I apply the completions and actions to the initial (usually the + command) word + + When completion is attempted, the actions are applied in the order the + uppercase-letter options are listed above. If multiple options are + supplied, + the -D option takes precedence over -E, and both take precedence over - + I. + + Exit Status: + Returns success unless an invalid option is supplied or an error occurs. + + [compgen] Display possible completions depending on the options. + + Intended to be used from within a shell function generating possible + completions. If the optional WORD argument is supplied, matches + against WORD are generated. + + Exit Status: + Returns success unless an invalid option is supplied or an error occurs. + + [compopt] Modify or display completion options. + + Modify the completion options for each NAME, or, if no NAMEs are + supplied, + the completion currently being executed. If no OPTIONs are given, + print the completion options for each NAME or the current completion + specification. + + Options: + -o option Set completion option OPTION for each NAME + -D Change options for the \default\ command completion + -E Change options for the \empty\ command completion + -I Change options for completion on the initial word + + Using `+o' instead of `-o' turns off the specified option. + + Arguments: + + Each NAME refers to a command for which a completion specification must + have previously been defined using the `complete' builtin. If no NAMEs + are supplied, compopt must be called by a function currently generating + completions, and the options for that currently-executing completion + generator are modified. + + Exit Status: + Returns success unless an invalid option is supplied or NAME does not + have a completion specification defined. + + [mapfile] Read lines from the standard input into an indexed array variable. + + Read lines from the standard input into the indexed array variable + ARRAY, or from file descriptor FD if the -u option is supplied. The variable + MAPFILE is the default ARRAY. + + Options: + -d delim Use DELIM to terminate lines, instead of newline + -n count Copy at most COUNT lines. If COUNT is 0, all lines are + copied + -O origin Begin assigning to ARRAY at index ORIGIN. The default + index is 0 + -s count Discard the first COUNT lines read + -t Remove a trailing DELIM from each line read (default newline) + -u fd Read lines from file descriptor FD instead of the standard + input + -C callback Evaluate CALLBACK each time QUANTUM lines are read + -c quantum Specify the number of lines read between each call to + CALLBACK + + Arguments: + ARRAY Array variable name to use for file data + + If -C is supplied without -c, the default quantum is 5000. When + CALLBACK is evaluated, it is supplied the index of the next array + element to be assigned and the line to be assigned to that element + as additional arguments. + + If not supplied with an explicit origin, mapfile will clear ARRAY + before assigning to it. + + Exit Status: + Returns success unless an invalid option is given or ARRAY is readonly + or not an indexed array. + + [readarray] Read lines from a file into an array variable. + + A synonym for `mapfile'. + + [unset] Unset values and attributes of shell variables and functions. + + For each NAME, remove the corresponding variable or function. + + Options: + -f treat each NAME as a shell function + -v treat each NAME as a shell variable + -n treat each NAME as a name reference and unset the variable itself + rather than the variable it references + + Without options, unset first tries to unset a variable, and if that + fails, + tries to unset a function. + + Some variables cannot be unset; also see `readonly'. + + Exit Status: + Returns success unless an invalid option is given or a NAME is read-only. + + [local] Remember or display program locations. + + Determine and remember the full pathname of each command NAME. If + no arguments are given, information about remembered commands is + displayed. + + Options: + -d forget the remembered location of each NAME + -l display in a format that may be reused as input + -p pathname use PATHNAME as the full pathname of NAME + -r forget all remembered locations + -t print the remembered location of each NAME, preceding + each location with the corresponding NAME if multiple + NAMEs are given + Arguments: + NAME Each NAME is searched for in $PATH and added to the list + of remembered commands. + + Exit Status: + Returns success unless NAME is not found or an invalid option is given. + + [export] Set export attribute for shell variables. + + Marks each NAME for automatic export to the environment of subsequently + executed commands. If VALUE is supplied, assign VALUE before + exporting. + + Options: + -f refer to shell functions + -n remove the export property from each NAME + -p display a list of all exported variables and functions + + An argument of `--' disables further option processing. + + Exit Status: + Returns success unless an invalid option is given or NAME is invalid. + + [readonly] Mark shell variables as unchangeable. + + Mark each NAME as read-only; the values of these NAMEs may not be + changed by subsequent assignment. If VALUE is supplied, assign VALUE + before marking as read-only. + + Options: + -a refer to indexed array variables + -A refer to associative array variables + -f refer to shell functions + -p display a list of all readonly variables or functions, + depending on whether or not the -f option is given + + An argument of `--' disables further option processing. + + Exit Status: + Returns success unless an invalid option is given or NAME is invalid. + + [typeset] Set variable values and attributes. + + A synonym for `declare'. See `help declare'. + + [source] Execute commands from a file in the current shell. + + Read and execute commands from FILENAME in the current shell. The + entries in $PATH are used to find the directory containing FILENAME. + If any ARGUMENTS are supplied, they become the positional parameters + when FILENAME is executed. + + Exit Status: + Returns the status of the last command executed in FILENAME; fails if + FILENAME cannot be read. + + [bind] Set Readline key bindings and variables. + + Bind a key sequence to a Readline function or a macro, or set a + Readline variable. The non-option argument syntax is equivalent to + that found in ~/.inputrc, but must be passed as a single argument: + e.g., bind '\\\C-x\\C-r\: re-read-init-file'. + + Options: + -m keymap Use KEYMAP as the keymap for the duration of this + command. Acceptable keymap names are emacs, + emacs-standard, emacs-meta, emacs-ctlx, vi, vi- + move, + vi-command, and vi-insert. + -l List names of functions. + -P List function names and bindings. + -p List functions and bindings in a form that can be + reused as input. + -S List key sequences that invoke macros and their + values + -s List key sequences that invoke macros and their + values + in a form that can be reused as input. + -V List variable names and values + -v List variable names and values in a form that can + be reused as input. + -q function-name Query about which keys invoke the named function. + -u function-name Unbind all keys which are bound to the named + function. + -r keyseq Remove the binding for KEYSEQ. + -f filename Read key bindings from FILENAME. + -x keyseq:shell-command\tCause SHELL-COMMAND to be executed when + \t\t\t\tKEYSEQ is entered. + -X List key sequences bound with -x and associated + commands + in a form that can be reused as input. + + Exit Status: + bind returns 0 unless an unrecognized option is given or an error occurs. + + [test] Evaluate arithmetic expressions. + + Evaluate each ARG as an arithmetic expression. Evaluation is done in + fixed-width 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. + + \tid++, id--\tvariable post-increment, post-decrement + \t++id, --id\tvariable pre-increment, pre-decrement + \t-, +\t\tunary minus, plus + \t!, ~\t\tlogical and bitwise negation + \t**\t\texponentiation + \t*, /, %\t\tmultiplication, division, remainder + \t+, -\t\taddition, subtraction + \t<<, >>\t\tleft and right bitwise shifts + \t<=, >=, <, >\tcomparison + \t==, !=\t\tequality, inequality + \t&\t\tbitwise AND + \t^\t\tbitwise XOR + \t|\t\tbitwise OR + \t&&\t\tlogical AND + \t||\t\tlogical OR + \texpr ? expr : expr + \t\t\tconditional operator + \t=, *=, /=, %=, + \t+=, -=, <<=, >>=, + \t&=, ^=, |=\tassignment + + Shell variables are allowed as operands. The name of the variable + is replaced by its value (coerced to a fixed-width integer) within + an expression. The variable need not have its integer attribute + turned on to be used in an expression. + + Operators are evaluated in order of precedence. Sub-expressions in + parentheses are evaluated first and may override the precedence + rules above. + + Exit Status: + If the last ARG evaluates to 0, let returns 1; let returns 0 otherwise. + *[other] show other command help info. + } + +helpname = { +$cmdName -> +[set] set - Set or unset values of shell options and positional parameters. +[read] read - Read a line from the standard input and split it into fields. +[type] type - Display information about command type. +[trap] trap - Trap signals and other events. +[alias] alias - Define or display aliases. +[unalias] unalias - Remove each NAME from the list of defined aliases. +[break] break - Exit for, while, or until loops. +[continue] continue - Resume for, while, or until loops. +[builtin] builtin - Execute shell builtins. +[caller] caller - Returns the context of the current subroutine call. +[cd] cd - Change the shell working directory. +[pwd] pwd - Print the name of the current working directory. +[true] true - Null command. +[shopt] shopt - Set and unset shell options. +[false] false - Return an unsuccessful result. +[command] command - Execute a simple command or display information about commands. +[echo] echo - Write arguments to the standard output. +[enable] enable - Enable and disable shell builtins. +[getopts] getopts - Parse option arguments. +[exec] exec - Replace the shell with the given command. +[exit] exit - Exit the shell. +[logout] logout - Exit a login shell. +[fc] fc - Display or execute commands from the history list. +[fg] fg - Resume job in foreground. +[bg] bg - Move jobs to the background. +[hash] hash - Remember or display program locations. +[help] help - Display information about builtin commands. +[history] history - Display or manipulate the history list. +[jobs] jobs - Display status of jobs. +[disown] discow - Remove jobs from current shell. +[kill] kill - Send a signal to a job. +[let] let - Evaluate arithmetic expressions. +[shift] shift - Shift positional parameters. +[suspend] suspend - Suspend shell execution. +[eval] eval - Evaluate conditional expression. +[times] times - Display process times. +[limit] limit - Modify shell resource limits. +[umask] umask - Display or set file mode mask. +[return] return - Wait for job completion and return exit status. +[wait] wait -Wait for process completion and return exit status. +[for] for - Execute commands for each member in a list. +[select] select - Select words from a list and execute commands. +[time] time - Report time consumed by pipeline's execution. +[case] case - Execute commands based on pattern matching. +[if] if - Execute commands based on conditional. +[while] while - Execute commands as long as a test succeeds. +[until] until - Execute commands as long as a test does not succeed. +[coproc] corproc - Create a coprocess named NAME. +[variables] variables - Common shell variable names and usage. +[pushd] pushd - Add directories to stack. +[popd] popd - Removes entries from the directory stack. +[dirs] dirs - Display the list of currently remembered directories. +[printf] printf - Formats and prints ARGUMENTS under control of the FORMAT. +[complete] complete - Specify how arguments are to be completed by Readline. +[compgen] compgen - Display possible completions depending on the options. +[compopt] compopt - Modify or display completion options. +[mapfile] mapfile - Read lines from the standard input into an indexed array variable. +[unset] unset - Unset values and attributes of shell variables and functions. +[readarray] readarry - Read lines from a file into an array variable. +[local] local -Remember or display program locations.。 +[export] export - Set export attribute for shell variables. +[readonly] readonly - Mark shell variables as unchangeable. +[function] function - Define shell function. +[typeset] typeset - Set variable values and attributes. +[source] source - Execute commands from a file in the current shell. +[bind] bind - Set Readline key bindings and variables.。 +[test] test - Evaluate arithmetic expressions. +*[other] show other command help info.. +} \ No newline at end of file diff --git a/bash-5.1/resources/zh-CN/message.ftl b/bash-5.1/resources/zh-CN/message.ftl new file mode 100644 index 0000000000000000000000000000000000000000..4ca3b5f17118804aa1aca8653b98b8180a36cb1a --- /dev/null +++ b/bash-5.1/resources/zh-CN/message.ftl @@ -0,0 +1,1340 @@ +helplongdoc ={ +$cmdName -> +[set] + 设定或取消设定 shell 选项和位置参数的 + + 改变 shell 选项和位置参数的值,或者显示 shell 变量的 + 名称和值。 + + 选项: + -a 标记修改的或者创建的变量为导出。 + -b 立即通告任务终结。 + -e 如果一个命令以非零状态退出,则立即退出。 + -f 禁用文件名生成(模式匹配)。 + -h 当查询命令时记住它们的位置 + -k 所有的赋值参数被放在命令的环境中,而不仅仅是 + 命令名称之前的参数。 + -m 启用任务控制。 + -n 读取命令但不执行 + -o 选项名 + 设定与选项名对应的变量: + allexport 与 -a 相同 + braceexpand 与 -B 相同 + emacs 使用 emacs 风格的行编辑界面 + errexit 与 -e 相同 + errtrace 与 -E 相同 + functrace 与 -T 相同 + hashall 与 -h 相同 + histexpand 与 -H 相同 + history 启用命令历史 + ignoreeof shell 读取文件结束符时不会退出 + interactive-comments + 允许在交互式命令中显示注释 + keyword 与 -k 相同 + monitor 与 -m 相同 + noclobber 与 -C 相同 + noexec 与 -n 相同 + noglob 与 -f 相同 + nolog 目前可接受但是被忽略 + notify 与 -b 相同 + nounset 与 -u 相同 + onecmd 与 -t 相同 + physical 与 -P 相同 + pipefail 管道的返回值是最后一个非零返回值的命令的返回结果, + 或者当所有命令都返回零是也为零。 + posix 改变默认时和 Posix 标准不同的 bash 行为 + 以匹配标准 + privileged 与 -p 相同 + verbose 与 -v 相同 + vi 使用 vi 风格的行编辑界面 + xtrace 与 -x 相同 + -p 无论何时当真实的有效的用户身份不匹配时打开。 + 禁用对 $ENV 文件的处理以及导入 shell 函数。 + 关闭此选项会导致有效的用户编号和组编号设定 + 为真实的用户编号和组编号 + -t 读取并执行一个命令之后退出。 + -u 替换时将为设定的变量当作错误对待。 + -v 读取 shell 输入行时将它们打印。 + -x 执行命令时打印它们以及参数。 + -B shell 将执行花括号扩展。 + -C 设定之后禁止以重定向输出的方式覆盖常 + 规文件。 + -E 设定之后 ERR 陷阱会被 shell 函数继承。 + -H 启用 ! 风格的历史替换。当 shell 是交互式的 + 时候这个标识位默认打开。 + -P 设定之后类似 cd 的会改变当前目录的命令不 + 追踪符号链接。 + -T 设定之后 DEBUG 陷阱会被 shell 函数继承。 + -- 任何剩余的参数会被赋值给位置参数。如果没 + 有剩余的参数,位置参数不会被设置。 + - 任何剩余的参数会被赋值给位置参数。 + -x 和 -v 选项已关闭。 + + 使用 + 而不是 - 会使标志位被关闭。标志位也可以在 + shell 被启动时使用。当前的标志位设定可以在 $- 变 + 量中找到。剩余的 ARG 参数是位置参数并且是按照 + $1, $2, .. $n 的顺序被赋值的。如果没有给定 ARG + 参数,则打印所有的 shell 变量。 + + 退出状态: + 返回成功除非使用了无效的参数。 + [read] 从标准输入读取一行并将其分为不同的域。 + + 从标准输入读取单独的一行,或者如果使用了 -u 选项,从文件描述符 FD 中读 + 取。 + 该行被分割成域,如同词语分割一样,并且第一个词被赋值给第一个 NAME 变量, + 第二 + 个词被赋值给第二个 NAME 变量,如此继续,直到剩下所有的词被赋值给最后一个 + NAME + 变量。只有 $IFS 变量中的字符被认作是词语分隔符。 + + 如果没有提供 NAME 变量,则读取的行被存放在 REPLY 变量中。 + + 选项: + -a array\t将词语赋值给 ARRAY 数组变量的序列下标成员,从零开始 + -d delim\t持续读取直到读入 DELIM 变量中的第一个字符,而不是换行符 + -e\t使用 Readline 获取行 + -i text\t使用 TEXT 文本作为 Readline 的初始文字 + -n nchars\t读取 nchars 个字符之后返回,而不是等到读取换行符。 + \t\t但是分隔符仍然有效,如果遇到分隔符之前读取了不足 nchars 个字符。 + -N nchars\t在准确读取了 nchars 个字符之后返回,除非遇到文件结束符或者读 + 超时, + \t\t任何的分隔符都被忽略 + -p prompt\t在尝试读取之前输出 PROMPT 提示符并且不带 + \t\t换行符 + -r\t不允许反斜杠转义任何字符 + -s\t不回显终端的任何输入 + -t timeout\t如果在 TIMEOUT 秒内没有读取一个完整的行则超时并且返回失 + 败。 + \t\tTMOUT 变量的值是默认的超时时间。TIMEOUT 可以是小数。 + \t\t如果 TIMEOUT 是 0,那么仅当在指定的文件描述符上输入有效的时候, + \t\tread 才返回成功;否则它将立刻返回而不尝试读取任何数据。 + \t\t如果超过了超时时间,则返回状态码大于 128 + -u fd\t从文件描述符 FD 中读取,而不是标准输入 + + 退出状态: + 返回码为零,除非遇到了文件结束符、读超时(且返回码不大于128)、 + 出现了变量赋值错误或者无效的文件描述符作为参数传递给了 -u 选项。 + + [type] 显示命令类型的信息。 + + 对于每一个 NAME 名称,指示如果作为命令它将如何被解释。 + + 选项: + -a\t显示所有包含名称为 NAME 的可执行文件的位置; + \t\t包括别名、内建和函数。仅当 `-p' 选项没有使用时 + -f\t抑制 shell 函数查询 + -P\t为每个 NAME 名称惊醒 PATH 路径搜索,即使它是别名、 + \t\t内建或函数,并且返回将被执行的磁盘上文件的名称。 + -p\t返回将被执行的磁盘上文件的名称,或者当 `type -t NAME' + \t不返回 `file' 时,不返回任何值。 + -t\t返回下列词中的任何一个 `alias'、`keyword'、 + \t`function'、`builtin'、`file' 或者 `',相应地如果 NAME 是 + \t一个别名、shell 保留字、shell 函数、shell 内建、 + \t磁盘文件或没有找到。 + + 参数: + NAME\t将要解析的命令。 + + 退出状态: + 返回成功,除非使用了无效的选项或者 NAME 名称为只读。 + + [trap] 对信号和其他事件设陷阱。 + + 定义一个处理器,在 shell 接收到信号和其他条件下执行。 + + ARG 参数是当 shell 接收到 SIGNAL_SPEC 信号时读取和执行的命令。 + 如果没有指定 ARG 参数 (并且只给出一个 SIGNAL_SPEC 信号) 或者 + ARG 参数为 + `-',每一个指定的参数会被重置为原始值。如果 ARG 参数是一个空串,则每一 + 个 + SIGNAL_SPEC 信号会被 shell 和它启动的命令忽略。 + + 如果一个 SIGNAL_SPEC 信号是 EXIT (0) ,则 ARG 命令会在 shell 退出时被 + 执行。如果一个 SIGNAL_SPEC 信号是 DEBUG,则 ARG命令会在每一个简单命 + 令之前执行。 + + 如果不提供参数,trap 打印列表显示每一个与每一个信号相关联的命令。 + + 选项: + -l\t打印一个信号名称和它们对应的编号的列表 + -p\t打印与每个 SIGNAL_SPEC 信号相关联的陷阱命令 + + 每一个 SIGNAL_SPEC 信号可以是 中的信号名称或者信号编号。 + 信号名称大小写敏感且可以使用 SIG 前缀。信号可用 \kill -信号 $$\ + 发送给 shell。 + + 返回成功,除非使用了无效的选项或者 SIGSPEC。 + + [alias] 定义或显示别名。 + + 不带参数时,`alias' 以可重用的格式 + `alias 名称=值'在标准输出设备上打印别名列表。 + + 否则,对于每个给定值的名称定义一个别名。 + 值末尾的空格会使下一个词被检测作为别名替换展开。 + + 选项: + -p\t以可重用的格式打印所有的已定义的别名 + + 退出状态: + 除非一个没有定义的名字被作为参数提供,否则 alias + 返回值为真。 + + [unalias] 从别名定义列表中删除每一个“名字”。 + + 选项: + -a\t删除所有的别名定义 + + 返回成功,除非“名字”不是一个已存在的别名。 + + [break] 退出 for、while 或 until 循环 + + 退出一个 FOR、WHILE 或 UNTIL 循环。如果指定了N,则跳出N重 + 循环 + + 退出状态: + 退出状态为0除非 N 不大于或等于 1。 + + [continue] 继续 for、while 或 until 循环。 + + 继续当前 FOR、WHILE 或 UNTIL 循环的下一步。 + 如果指定了 N, 则继续当前的第 N 重循环。 + + 退出状态: + 退出状态为 0 除非 N 不大于或等于1。 + + [builtin] 执行 shell 内建。 + + 带参数 ARGs 执行 SHELL-BUILTIN 内建,并且不做命令查询 + 在希望以 shell 函数的形式来重新实现 shell 内建, + 并且希望在函数之内执行该 shell 内建的情况下有用处。 + + 退出状态: + 以 SHELL-BUILTIN 内建的退出状态为准,或者如果 SHELL-BUILTIN 不是一个 + shell 内建时为假。 + + [caller] 返回当前子调用的上下文。 + + 不带有 EXPR 时,返回 \$line $filename\。带有 EXPR 时,返回 + \$line $subroutine $filename\;这个额外的信息可以被用于提供 + 栈追踪。 + + EXPR 的值 显示了到当前调用帧需要回去多少个调用帧;顶部帧 + 是第 0 帧。 + + 退出状态: + 除非 shell 不在执行一个 shell 函数或者 EXPR 无效,否则返回结 + 果为0。 + + [cd]改变 shell 工作目录。 + + 改变当前目录至 DIR 目录。默认的 DIR 目录是 shell 变量 HOME + 的值。 + + 变量 CDPATH 定义了含有 DIR 的目录的搜索路径,其中不同的目录名称由冒号 (:) + 分隔。 + 一个空的目录名称表示当前目录。如果要切换到的 DIR 由斜杠 (/) 开头,则 + CDPATH + 不会用上变量。 + + 如果路径找不到,并且 shell 选项 `cdable_vars' 被设定,则参数词被假定为一 + 个 + 变量名。如果该变量有值,则它的值被当作 DIR 目录。 + + 选项: + -L\t强制跟随符号链接: 在处理 `..' 之后解析 DIR 中的符号链接。 + -P\t使用物理目录结构而不跟随符号链接: 在处理 `..' 之前解析 DIR 中的符 + 号链接。 + -e\t如果使用了 -P 参数,但不能成功确定当前工作目录时,返回非零的返回 + 值。 + -@\t在支持拓展属性的系统上,将一个有这些属性的文件当作有文件属性的目 + 录。 + + 默认情况下跟随符号链接,如同指定 `-L'。 + `..' 使用移除向前相邻目录名成员直到 DIR 开始或一个斜杠的方式处理。 + + 退出状态: + 如果目录改变,或在使用 -P 选项时 $PWD 修改成功时返回 0,否则非零。 + + [pwd]打印当前工作目录的名字。 + + 选项: + -L\t打印 $PWD 变量的值,如果它包含了当前的工作目录 + -P\t打印当前的物理路径,不带有任何的符号链接 + + 默认情况下,`pwd' 的行为和带 `-L' 选项一致 + + 退出状态: + 除非使用了无效选项或者当前目录不可读,否则返回状态为0。 + + [true]空的命令。 + + 没有效果; 此命令不做任何操作。 + + 退出状态: + 总是成功。 + [shopt] 设定和取消设定 shell 选项。 + + 改变每个 shell 选项 OPTNAME 的设定。不带参数时, + 列出每个提供的 OPTNAME,否则列出所有 shell 选项; + 同时标注每一个选项是否被设定。 + + 选项: + -o\t限制 OPTNAME 为定义用于`set -o' 的选项 + -p\t打印每个 shell 选项并标注它的状态。 + -q\t抑制输出 + -s\t启用(设定)每个 OPTNAME 选项 + -u\t禁用(取消设定)每个 OPTNAME 选项 + + 退出状态: + 如果 OPTNAME 选项被启用则返回成功;如果是 + 无效的选项或 OPTNAME 被禁用则失败。 + + [false] 返回一个不成功的结果。 + + 退出状态: + 总是失败。 + + [command] 执行一个简单命令或者显示命令的相关信息。 + + 带 ARGS 参数运行 COMMAND 命令且抑制 shell 函数查询,或显示 + 指定的 COMMAND 命令的信息。可以在存在相同名称的函数定义的 + 情况下用于启动磁盘上的命令。 + + 选项: + -p\t使用 PATH 变量的一个默认值以确保所有的标准工具都能被找到。 + -v\t打印 COMMAND 命令的描述,和 `type' 内建相似 + -V\t打印每个 COMMAND 命令的详细描述 + + 退出状态 + 返回 COMMAND 命令的返回状态,或者当找不到 COMMAND 命令时失败。 + + [echo] 将参数写到标准输出。 + + 在标准输出上,显示用空格分割的 ARG 参数后跟一个换行。 + + 选项: + -n\t不要追加换行 + -e\t启用下列反斜杠转义的解释 + -E\t显式地抑制对于反斜杠转义的解释 + + `echo' 对下列反斜杠字符进行转义: + \a\t警告(响铃) + \\b\t退格 + \\c\t抑制更多的输出 + \\e\t转义字符 + \\f\t换页字符 + \\t换行 + \\r\t回车 + \\t\t横向制表符 + \\v\t纵向制表符 + \\\\\t反斜杠 + \\0nnn\t以 NNN(八进制)为 ASCII 码的字符。NNN 可以是 0 到 3 个八进制 + 位 + \\xHH\t以 HH(十六进制)为值的八比特字符。HH 可以是一个或两个十六进制 + 位 + \\uHHHH\t以 HHHH(十六进制)为值的 Unicode 字符。HHHH 可以是一个到 + \t\t四个十六进制位。 + \\UHHHHHHHH 以 HHHHHHHH(十六进制)为值的 Unicode 字符。 + \t\tHHHHHHHH 可以是一到八个十六进制位。 + + 退出状态: + 返回成功除非有写错误发生。 + + 写参数至标准输出设备。 + + 在标准输出设备上显示 ARGs 参数和一个换行。 + + 选项: + -n\t不附加换行 + + 退出状态: + 除非写错误发生,否则返回成功。 + + [enable] 启用和禁用 shell 内建。 + + 启用和禁用 shell 的内建命令。禁用使您能够执行一个和内建 + 命令同名的磁盘上的命令,而无须使用完整的路径名。 + + + 选项: + -a\t打印一个内建的列表,并显示其中每一个是否启用 + -n\t禁用每一个 NAME 内建或者显示一个被禁用的内建的列表 + -p\t以可重用的格式打印一个内建的列表 + -s\t仅打印Posix `special' 内建的名称 + + 控制动态加载的选项: + -f\t从共享对象 FILENAME 文件中加载 NAME 内建 + -d\t删除以 -f 选项加载的内建 + + 不带选项时,每一个 NAME 内建都被启用。 + + 如果要使用 $PATH 中找到的 `test' 而不是 shell 内建的版本, + 输入 `enable -n test'。 + + 退出状态: + 返回成功,除非 NAME 不是一个 shell 内建或者有错误发生。 + + [getopts] 解析选项参数。 + + getopts 被 shell 过程用于解析可定位的参数作为选项。 + + + OPTSTRING 字符串包含待识别的选项字母;如果一个字母后面跟 + 着分号,则该选项需要一个参数,而该参数应用空格与选项分开。 + + + 每次启动时,getopts 会将下一个选项放到 shell 变量 $name + 中,如果 name 变量不存在则先将其初始化,而下一个待处 + 理的参数序号放入 shell 变量 OPTIND 中。OPTIND 变量在每 + 次 shell 或者 shell 脚本启动时都被初始化为1。当一个选项要 + 求有一个参数时,getopts 将参数放入 shell 变量 OPTARG + 中。 + + getopts 有两种报告错误的方法。如果 OPTSTRING 变量的第 + 一个字符是冒号,getopts 使用沉默错误报告。在这种模式 + 下,不会打印错误消息。如果看到了一个无效的选项, + getopts 将找到的选项字符放至 OPTARG 变量中。如果一个必 + 须的选项没有找到,getopts 放一个 ':' 到 NAME 变量中并且设 + 置 OPTARG 变量为找到的选项字符。如果 getopts 不在沉默模 + 式中,并且遇到了一个无效的选项,getopts 放置一个 '?' 到 NAME + 变量中并且取消设定 OPTARG变量。如果必须的选项没有找到, + 一个'?'会被放入 NAME变量中,OPTARG 将被取消设定,并且会 + 打印一个诊断信息。 + + 如果 shell 变量 OPTERR 的值为0,getopts 禁用 + 错误信息的打印,即使 OPTSTRING 变量的第一个字符不是一 + 个冒号。OPTERR 的默认值为1. + + getopts 通常解析可定位的参数($0 - $9),不过如果提供了 + 更多的参数,它们反而会被解析。 + + 退出状态: + 如果一个选项被找到则返回成功;如果遇到了选项的结尾或者 + 有错误发生则返回失败。 + + [exec] 使用指定命令替换 shell。 + + 执行 COMMAND 命令,以指定的程序替换这个 shell。 + ARGUMENTS 参数成为 COMMAND命令的参数。如果 + 没有指定COMMAND 命令,则任何的重定向在当前 shell 中生效。 + + 选项: + -a 名称\t作为第0个参数传递给 COMMAND 命令 + -c\t\t在一个空环境中执行 COMMAND 命令 + -l\t\t在COMMAND 命令的第0个参数中加一个短线 + + 如果命令不能被执行,则退出一个非交互式的 shell,除非 + shell 选项`execfail' 已经设定。 + + 退出状态: + 返回成功除非 COMMAND 命令没有找到或者出现一个重定向错误。 + + [exit] 退出shell。 + + 以状态 N 退出 shell。 如果 N 被省略,则退出状态 + 为最后一个执行的命令的退出状态。 + + [logout] 退出一个登录 shell. + + 以状态 N 退出一个登录 shell。如果不在登录 shell 中执行,则 + 返回一个错误。 + + [fc] 从历史列表中显示或者执行命令。 + + fc 被用于从历史列表中列出或者重新编辑并执行命令。 + FIRST 和 LAST 变量可以是数字用于指定范围,或者 FIRST 可以是 + 字符串,意味着以这个字符串打头的最近的一个命令。 + + + 选项: + -e ENAME\t选择使用哪个编辑器。默认的是 FCEDIT, 然后是 EDITOR, + \t\t然后是 vi + -l \t列出行而不编辑 + -n\t列举时省略行号 + -r\t反转行的顺序(最新行在前) + + 用 `fc -s [模式=替换 ...] [命令]' 的格式,COMMAND 命令会在 OLD=NEW + 替换之后被重新执行。 + + r='fc -s' 是一个有用的别名,这样的话输入 `r cc'会执行最后一个以 `cc' + 开头的命令,输入 `r'会重新执行最后一个命令。 + + + 退出状态: + 返回成功,或者执行的命令的状态;如果错误发生则返回非零。 + + [fg] 将任务移至前台。 + + 将以 JOB_SPEC 标识的任务放至前台,使其成为 + 当前任务。如果 JOB_SPEC 不存在,shell 观念中的当前任务 + 将被使用。 + + 退出状态: + 放至前台的命令状态,或者当错误发生时为失败。 + + [bg] 移动任务至后台。 + + 将 JOB_SPEC 标识的任务放至后台,就像它们 + 是带 `&' 启动的一样。如果 JOB_SPEC 不存在,shell 观念中的 + 当前任务将会被使用。 + + 退出状态: + 返回成功除非任务管理没有启用或者错误发生。 + + [hash] 记住或显示程序位置。 + + 确定并记住每一个给定 NAME 名称的命令的完整路径。 + 如果不提供参数,则显示已经记住的命令的信息。 + + 选项: + -d\t\t忘记每一个已经记住的 NAME 的位置 + -l\t\t以可作为输入重用的格式显示 + -p pathname\t使用 pathname 路径作为 NAME 命令的全路径 + -r\t\t忘记所有记住的位置 + -t\t\t打印记住的每一个 NAME 名称的位置,如果指定了多个 + \t\tNAME 名称,则每个位置前面会加上相应的 NAME 名称 + \t\t + 参数: + NAME\t\t每个 NAME 名称会在 $PATH 路径变量中被搜索,并且添加到记住的命 + 令 + 列表中。 + + 退出状态: + 返回成功,除非 NAME 命令没有找到或者使用了无效的选项。 + + [help] 显示内建命令的相关信息。 + + 显示内建命令的简略信息。如果指定了 PATTERN 模式, + 给出所有匹配 PATTERN 模式的命令的详细帮助,否则打 + 印一个帮助主题列表 + + 选项: + -d\t输出每个主题的简短描述 + -m\t以伪 man 手册的格式显示使用方法 + -s\t为每一个匹配 PATTERN 模式的主题仅显示一个用法 + \t简介 + + 参数: + PATTERN\t指定帮助主题的模式 + + 退出状态: + 返回成功,除非未找到 PATTERN 模式没有找到或者使用了无效选项。 + + [history] 显示或操纵历史列表。 + + 带行号显示历史列表,将每个被修改的条目加上 `*' 前缀。 + 参数 N 会仅列出最后的 N 个条目。 + + 选项: + -c\t删除所有条目从而清空历史列表。 + -d 偏移量\t从指定位置删除历史列表。负偏移量将从历史条目末尾 + \t\t开始计数 + + -a\t将当前会话的历史行追加到历史文件中 + -n\t从历史文件中读取所有未被读取的行 + \t\t并且将它们附加到历史列表 + -r\t读取历史文件并将内容追加到历史列表中 + -w\t将当前历史写入到历史文件中 + + -p\t对每一个 ARG 参数展开历史并显示结果,而不存储到历史列表中 + -s\t以单条记录追加 ARG 到历史列表中 + + 如果给定了 FILENAME 文件名,则它将被作为历史文件。否则 + 如果 $HISTFILE 变量有值的话使用之,不然使用 ~/.bash_history 文件。 + + 如果 $HISTTIMEFORMAT 变量被设定并且不为空,它的值会被用于 + strftime(3) 的格式字符串来打印与每一个显示的历史条目想关联的 + 时间戳,否则不打印时间戳。 + + 退出状态: + 返回成功,除非使用了无效的选项或者发生错误。 + [jobs] 显示任务状态。 + + 列出活动的任务。JOBSPEC 限制仅输出指定的任务。 + 不带选项时,所有活动任务的状态都会显示。 + + 选项: + -l\t在正常信息基础上列出进程号 + -n\t仅列出上次通告之后改变了状态的进程 + -p\t仅列出进程号 + -r\t限制仅输出运行中的任务 + -s\t限制仅输出停止的任务 + + 如果使用了 -x 选项,ARG 参数中的所有任务声明会被替换为该任务 + 的进程组头领的进程号,然后执行 COMMAND 命令。 + + 退出状态: + 返回成功,除非使用了无效的选项或者有错误发生。 + 如果使用 -x 选项,则返回 COMMAND 命令的退出状态。 + + [disown] 从当前 shell 中删除任务。 + + 从活动任务表中删除每一个 JOBSPEC 参数。不带任何 + JOBSPEC 参数时,shell 使用观念中的当前任务。 + + 选项: + -a\t如果不提供 JOBSPEC 参数,则删除所有任务 + -h\t标识每个 JOBSPEC 任务,从而当 shell 接收到 SIGHUP + \t\t信号时不发送 SIGHUP 给指定任务 + -r\t仅删除运行中的任务 + + 退出状态: + 返回成功除非使用了无效的选项或者 JOBSPEC 声明。 + + [kill] 向一个任务发送一个信号。 + + 向以 PID 进程号或者 JOBSPEC 任务声明指定的进程发送一个以 + SIGSPEC 信号声明或 SIGNUM 信号编号命名的信号。如果没有指定 + SIGSPEC 或 SIGNUM,那么假定发送 SIGTERM 信号。 + + 选项: + -s sig\tSIG 是信号名称 + -n sig\tSIG 是信号编号 + -l\t列出信号名称;如果参数后跟 `-l'则被假设为信号编号, + \t\t而相应的信号名称会被列出 + + Kill 成为 shell 内建有两个理由:它允许使用任务编号而不是进程号, + 并且在可以创建的进程数上限达到是允许进程被杀死。 + + 退出状态: + 返回成功,除非使用了无效的选项或者有错误发生。 + [let] 估值算术表达式。 + + 将每个 ARG 参赛作为算术表达式来估值。估值的计算以定宽的整 + 数完成,不带溢出检测,不过除 0 是被置陷阱的并且会报一个错 + 误。下列操作符被按照相同的算术优先级组合。列表的顺序按照 + 优先级从高至低。 + + + \tid++, id--\t变量后置加,后置减 + \t++id, --id\t变量前置加,前置减 + \t-, +\t\t一元减法,一元加法 + \t!, ~\t\t逻辑和位取反 + \t**\t\t指数 + \t*, /, %\t\t乘法,除法,取余数 + \t+, -\t\t增加,减少 + \t<<, >>\t\t向左和向右按位移位 + \t<=, >=, <, >\t比较 + \t==, !=\t\t等于,不等于 + \t&\t\t按位与 + \t^\t\t按位异或 + \t|\t\t按位或 + \t&&\t\t逻辑与 + \t||\t\t逻辑或 + \texpr ? expr : expr + \t\t\t条件操作符 + \t=, *=, /=, %=, + \t+=, -=, <<=, >>=, + \t&=, ^=, |=\t赋值 + + Shell 变量允许作为操作数。表达式中的变量的名称会被取代以值 + (强制转换为定宽的整数)。表达式中的变量不需要打开整数属性。 + + 操作符按照优先级进行估值。括号中的子表达式将被先估值,并可取代上述表达式 + 规则。 + + [shift] 移位位置参数。 + + 重命名位置参数 $N+1、$N+2 ... 到 $1、$2 ... 如果没有给定 N, + 则假设为1. + + 退出状态: + 返回成功,除非 N 为负或者大于 $#。 + 返回 N,或者如果 shell 不在执行一个函数或引用脚本时,失败。 + + [suspend] 挂起 shell 执行。 + + 挂起 shell 的执行直到收到 SIGCONT 信号。 + 登录 shell 不可以被挂起,除非强制执行。 + + 选项: + -f\t强制挂起,即使是登录 shell。 + + 退出状态: + 返回成功,除非没有启用任务控制或者有错误发生。 + + [eval] 对条件表达式进行估值。 + + 根据 EXPR 表达式的估值以状态 0 (真) 或 1 (伪) 退出。 + 表达式可以是一元或者二元的。一元表达式通常用于检测 + 文件状态。同时还有字符串操作符和数字比较操作符。 + + 文件操作符: + + -a 文件 如果文件存在则为真。 + -b 文件 如果文件为块特殊文件则为真。 + -c 文件 如果文件为字符特殊文件则为真。 + -d 文件 如果文件为目录则为真。 + -e 文件 如果文件存在则为真。 + -f 文件 如果文件存在且为常规文件则为真。 + -g 文件 如果文件的组属性设置打开则为真。 + -h 文件 如果文件为符号链接则为真。 + -L 文件 如果文件为符号链接则为真。 + -k 文件 如果文件的粘滞 (sticky) 位设定则为真。 + -p 文件 如果文件为命名管道则为真。 + -r 文件 如果文件对于您是可读的则为真。 + -s 文件 如果文件存在且不为空则为真。 + -S 文件 如果文件是套接字则为真。 + -t 文件描述符 如果文件描述符在一个终端上打开则为真。 + -u 文件 如果文件的用户数行设置打开则为真。 + -w 文件 如果文件对您是可写的则为真 + -x 文件 如果文件对您是可执行的则为真。 + -O 文件 如果文件是被您所有的则为真。 + -G 文件 如果文件被您的组所有则为真。 + -N 文件 如果文件上次被读取之后修改过则为真。 + + FILE1 -nt FILE2 如果 file1 文件新于 file2 文件则为真(根据 + 修改日期)。 + + FILE1 -ot FILE2 如果 file1 文件旧于 file2 文件则为真。 + + FILE1 -ef FILE2 如果 file1 文件是 file2 文件的硬链接则为真。 + + 字符串操作符 + + -z 字符串 如果字符串为空则为真。 + + -n 字符串 + 字符串 如果字符串不为空则为真。 + + STRING1 = STRING2 + 如果 string1 和 string2 字符串相同则为真。 + STRING1 != STRING2 + 如果 string1 和 string2 字符串不相同则为真。 + STRING1 < STRING2 + 如果按字典排序 string1 在 string2 串之前则为真。 + STRING1 > STRING2 + 如果按字典排序 string1 在 string2 串之前则为真。 + + 其他操作符: + + -o 选项 如果指定 shell 选项启用则为真。 + -v VAR 如果指定 Shell 变量 VAR 已赋值则为真。 + -R VAR 如果指定 Shell 变量 VAR 已赋值且为名称引用则为真。 + ! EXPR 如果表达式 expr 为假则为真。 + EXPR1 -a EXPR2 如果 expr1 和 expr2 都为真则为真。 + EXPR1 -o EXPR2 如果 expr1 和 expr2 有一个为真则为真。 + + arg1 OP arg2 算术测试。OP操作符可以是 -eq、-ne、 + -lt、-le、-gt、或 -ge 中的一个。 + + 二元算术操作返回真,如果 ARG1 参数等于、不等于、 + 小于、小于等于、大于、或者大于等于 ARG2 参数。 + + 退出状态: + 如果 EXPR 表达式估值为真则返回成功;如果 EXPR 表达式估值 + 为假或者使用了无效的参数则返回失败。 + + [times] 显示进程时间 + + 打印 shell 及其所有子进程的累计用户空间和 + 系统空间执行时间。 + + 退出状态 + 总是成功。 + + [limit] 修改 shell 资源限制。 + + 在允许此类控制的系统上,提供对于 shell 及其创建的进程所可用的 + 资源的控制。 + + 选项: + -S\t使用软 (`soft') 资源限制 + -H\t使用硬 (`hard') 资源限制 + -a\t所有当前限制都被报告 + -b\t套接字缓存尺寸 + -c\t创建的核文件的最大尺寸 + -d\t一个进程的数据区的最大尺寸 + -e\t最高的调度优先级 (`nice') + -f\t有 shell 及其子进程可以写的最大文件尺寸 + -i\t最多的可以挂起的信号数 + -k\t分配给此进程的最大 kqueue 数量 + -l\t一个进程可以锁定的最大内存尺寸 + -m\t最大的内存进驻尺寸 + -n\t最多的打开的文件描述符个数 + -p\t管道缓冲区尺寸 + -q\tPOSIX 信息队列的最大字节数 + -r\t实时调度的最大优先级 + -s\t最大栈尺寸 + -t\t最大的CPU时间,以秒为单位 + -u\t最大用户进程数 + -v\t虚拟内存尺寸 + -x\t最大的文件锁数量 + -P\t最大伪终端数量 + -T\t最大线程数量 + + 并非所有选项在所有系统上可用。 + + 如果提供了 LIMIT 变量,则它为指定资源的新的值;特别的 LIMIT 值为 + `soft'、`hard'和`unlimited',分别表示当前的软限制,硬限制和无限制。 + 否则打印指定资源的当前限制值,不带选项则假定为 -f + + 取值都是 1024 字节为单位,除了 -t 以秒为单位,-p 以 512 字节递增, + -u 为无范围的进程数量。 + + 退出状态: + 返回成功,除非使用了无效的选项或者错误发生。 + + [umask] 显示或设定文件模式掩码。 + + 设定用户文件创建掩码为 MODE 模式。如果省略了 MODE,则 + 打印当前掩码的值。 + + 如果 MODE 模式以数字开头,则被当作八进制数解析;否则是一个 + chmod(1) 可接收的符号模式串。 + + 选项: + -p\t如果省略 MODE 模式,以可重用为输入的格式输入 + -S\t以符号形式输出,否则以八进制数格式输出 + + 退出状态: + 返回成功,除非使用了无效的 MODE 模式或者选项。 + + [return] 等待任务完成并返回退出状态。 + + 等待以 ID 编号识别的进程,其中 ID 可以是进程编号或者任务声明, + 并报告它的终止状态。如果 ID 没有给出,则等待所有的当前活跃子 + 进程,并且返回状态为零。如果 ID 是任务声明,等待任务管道中的 + 所有进程。 + + 若给定了 -n 选项,等待下一个任务完成并返回其状态。 + + 若给定了 -f 选项,且已启用了任务控制,则等待指定的 ID 终止 + 而非等待它改变状态。 + 退出状态: + 返回最后一个 ID 进程的状态;如果使用了无效的 ID 或者选项则失败。 + + [wait] 等待进程完成并且返回退出状态。 + + 等待指定进程并报告它的终止状态。如果没有提供 PID,则当前所有的活跃 + 子进程都会被等待,并且返回码为零。PID 必须为进程号。 + + 退出状态: + 返回进程 ID 的状态;如果 PID 是无效的进程号或者指定了无效的选项则失败。 + + [for] 为列表中的每个成员执行命令。 + + “for”循环为列表中的每个成员执行一系列的命令。如果没有 + “in <词语> ...;”则假定使用“in \$@\”。对于 <词语> 中的每 + 个元素,<名称> 变量被设定为该元素后执行 <命令>。 + + 退出状态: + 返回最后执行的命令的状态。 + + [select] 从列表中选取词并且执行命令。 + + <词语...> 被展开,生成一个词的列表。展开的词集合被打印 + 在标准错误输出设备上,每个以一个数字做前缀。如果没有 `in WORDS' + 则假定使用`in \$@\'。PS3提示符会被显示并且从标准输入读入一行 + 如果该行由被显示的词对应的数字组成,则 NAME 变量被设定为相应 + 的词。如果行为空,则 WORDS 变量和提示符被重新显示。如果读取了 + 文件结束符,则命令完成。读入任何其他的值会导致 NAME 变量被设定 + 为空。读入的行被存放在变量 REPLY 中。COMMANDS 命令在每次选择 + 之后执行直到执行一个 break 命令。 + + 退出状态: + 返回最后一个执行的命令的状态。 + + [time] 报告管道执行的消耗时间。 + + 执行 PIPELINE 并且打印 PIPELINE 终结时实际时间、用户 CPU 时间和系统 + CPU 时间的总结。 + + 选项: + -p\t用可迁移的 POSIX 格式打印用时总结。 + + TIMEFORMAT 变量的值被作为输出格式。 + + 退出状态: + 返回状态即PIPELINE 的返回状态。 + + [case] 基于模式匹配来执行命令。 + + 基于 PATTERN 模式匹配的词 WORD,有选择的执行 COMMANDS 命令。 + `|' 用于分隔多个模式。 + + 退出状态: + 返回最后一个执行的命令的状态。 + + [if] 根据条件执行命令。 + + `if COMMANDS'列表被执行。如果退出状态为零,则执行`then COMMANDS' + 列表。否则按顺序执行每个 `elif COMMANDS'列表,并且如果它的退出状态为 + 零,则执行对应的 `then COMMANDS' 列表并且 if 命令终止。否则如果存在的 + 情况下,执行 `else COMMANDS'列表。整个结构的退出状态是最后一个执行 + 的命令的状态,或者如果没有条件测试为真的话,为零。 + + 退出状态: + 返回最后一个执行的命令的状态。 + + [while] 只要测试成功即执行命令。 + + 只要在 `while' COMMANDS 中的最终命令返回结果为0,则 + 展开并执行 COMMANDS 命令。 + + 退出状态: + 返回最后一个执行的命令的状态。 + + [until] 当测试不同过时执行命令。 + + `until' COMMANDS 命令的最终命令返回状态不为 0 时, + 展开并执行 COMMANDS 命令。 + + 退出状态: + 返回最后一个执行的命令的状态。 + + [coproc] 创建一个以 NAME 为名的副进程。 + + 异步执行 COMMANDS 命令,在执行 shell 中的数组变量 NAME + 的 0 号和 1 号元素作为文件描述符,以一个管道连接命令 + 分别作为命令的标准输出和输入设备。 + 默认的 NAME 是 \COPROC\。 + + 退出状态: + 副进程会返回退出状态 0。 + + [variables] 常用 shell 变量名称和使用。 + + BASH_VERSION\t当前 Bash 的版本信息。 + CDPATH\t用于 `cd' 命令参数搜索的分号分隔的目录列表 + GLOBIGNORE\t路径扩展时忽略的文件名匹配模式列表, + \t\t以分号分隔。 + HISTFILE\t您的命令历史存放的文件名称。 + HISTFILESIZE\t历史文件最多可以保存的行数。 + HISTSIZE\t一个运行的 shell 最多可以访问的历史命令行数。 + HOME\t您的登录目录的完整路径。 + HOSTNAME\t当前主机的主机名。 + HOSTTYPE\t当前版本的 BASH 在其之上运行的 CPU 类型。 + IGNOREEOF\t控制 shell 收到文件结束符作为单一输入后的 + \t\t动作。如果设定这个变量,则它的值是 shell 退出之前在 + \t\t一个空行上可以连续看到的文件结束符数量(默认为10)。 + \t\t未设定时,文件结束符标志着输入的结束。 + MACHTYPE\t描述当前运行 Bash 的系统的字符串。 + MAILCHECK\tBash 检测新邮件的频率,以秒为单位。 + MAILPATH\tBash 从中检测新邮件的文件列表,以分号分隔。 + OSTYPE\t运行 Bash 的 Unix 版本。 + PATH\t当寻找命令时搜索的目录列表,以冒号分隔。 + PROMPT_COMMAND\t打印每一个主提示符之前执行的命 + \t\t令。 + PS1\t\t主提示符字符串。 + PS2\t\t从提示符字符串。 + PWD\t\t当前目录的完整路径。 + SHELLOPTS\t已启用的 shell 选项列表,以冒号分隔。 + TERM\t当前终端类型的名称。 + TIMEFORMAT\t以关键则 `time' 显示的时间统计信息的输出 + \t\t格式。 + auto_resume\t非空时,一个单独的命令词会首先被在当前 + \t\t停止的任务列表中搜索。如果找到则该任务被置于前台。 + \t\t如果值为 `exact' 则意味着命令词必须精确匹配停止任务 + \t\t列表中的命令。如果值为 `substring' 则意味着命令词必 + \t\t须匹配任务的一个子字符串。任何其他的值意味着命令词 + \t\t必须是停止任务的一个前缀。 + histchars\t控制历史展开和快速替换的字符。第一个字符是 + \t\t历史替换字符,通常是 `!'。第二个字符是快速替换字符, + \t\t通常是 `^'。第三个是历史注释字符,通常是 `#'。 + HISTIGNORE\t用于决定哪些命令被存入历史文件的模式 + \t\t列表,以冒号分隔。 + + [pushd] 将目录添加到栈中。 + + 将目录添加到目录栈顶,或着旋转栈直到当前工作目录成为 + 新的栈顶。不带参数时,交换栈顶的两个目录。 + + 选项: + -n\t抑制添加目录至栈时通常的改变目录操作,从而仅对栈 + \t进行操作。 + + 参数: + +N\t旋转栈从而第 N 个目录 (`dirs' 显示的列表中左起,从零开始) + \t将移动到栈顶。 + + -N\t旋转栈从而第 N 个目录 (`dirs' 显示的列表中右起,从零开始) + \t将移动到栈顶。 + + dir\t将 DIR 目录添加到栈顶,并且使其成为当前工作目录。 + + `dirs' 内建显示目录栈。 + + 退出状态: + + [popd] 从栈中删除目录。 + + 从目录栈中删除条目。不带参数时,删除栈顶目录,并改变至新的栈 + 顶目录。 + + 选项: + -n\t抑制从栈中删除目录时通常的目录变换操作,从而仅对栈 + \t进行操作。 + + 参数: + +N\t删除第 N 个目录 (`dirs' 显示的目录列表中左起,从零开始)。 + \t例如:`popd +0' 删除第一个目录,`popd +1' 删除第二个。 + + -N\t删除第 N 个目录 (`dirs' 显示的目录列表中右起,从零开始)。 + \t例如:`popd -0' 删除最后一个目录,,`popd -1' 删除倒数第二个。 + + `dirs' 内建显示目录栈。 + + 退出状态: + 返回成功,除非使用了无效的参数或者目录变换失败。 + + [dirs] 显示目录栈。 + + 显示当前记住的目录列表。通过 `pushd' 命令可以将目录存入列表 + 中;`popd' 命令可用于遍历弹出列表。 + + 选项: + -c\t删除所有元素以清空目录栈 + -l\t不打印与主目录相关的波浪号前缀的目录 + -p\t每行一个条目打印目录栈 + -v\t每行一个条目,以栈中位置为前缀打印目录栈 + + 参数: + +N\t显示 dirs 不带选项启动时显示的目录列表左起中第 + \tN 个目录,从零开始。 + + -N\t显示 dirs 不带选项启动时显示的目录列表右起中第 + \tN 个目录,从零开始。 + + 退出状态: + 返回成功,除非使用了无效的选项或者发生错误。 + + [printf] 在 FORMAT 的控制下格式化并打印 ARGUMENTS 参数。 + + 选项: + -v var\t将输出赋值给 shell 变量 VAR 而不显示在标准输出上 + + FORMAT 是包含三种对象的字符串:简单地被拷贝到标准输出的普通字符; + 被变换之后拷贝到标准输入的转义字符;以及每个都会影响到下个参数的打印的格 + 式化声明。 + + 在 printf(1) 中描述的标准控制声明之外,printf 解析: + + %b\t扩展对应参数中的反斜杠转义序列 + %q\t以可作为 shell 输入的格式引用参数 + %(fmt)T\t以 FMT 为供给 strftime(3) 的格式输出日期时间字符串 + + 退出状态: + 返回成功,除非使用了无效的选项或者写或赋值错误发生。 + + [complete] 指定 Readline 如何补全参数。 + + 声明对于每一个 NAME 名称如何补全参数。如果不带选项, + 现有的补全声明会以可以重用为输入的格式打印出来。 + + 选项: + -p\t以可重用的格式打印现有的补全声明。 + -r\t对于每个 NAME 名称删除补全声明,或者如果没有提供 NAME + \t名称,删除所有的补全声明。 + -D\t对于没有补全声明定义的命令,设定默认的补全动作 + -E\t对于 \empty\ 命令设定补全动作,—— 对于空行的补全。 + -I\t将补全和动作应用在首单词(通常是所给命令)上 + + 尝试补全时,按照上述大写字母选项的顺序进行动作。 + 如果给出了多个选项,-D 选项优先级高于 -E 选项,且 + 这两个选项优先级均高于 -I。 + + 退出状态: + 返回成功,除非使用了无效的选项或者错误发生。 + + [compgen] 依据选项显示可能的补全。 + + 意图在能产生可能的补全的 shell 函数内部使用。 + 如果提供了可选的 WORD 参数,则产生按照 WORD + 进行的匹配。 + + 退出状态: + 除非使用了无效选项或者错误发生,否则返回成功。 + + [compopt] 修改或显示补全选项。 + + 修改每个 NAME 名称的补全选项,或如果没有提供 NAME 名称,执行当前的补 + 全。 + 如果不带选项,打印每个 NAME 名称的补全选项或当前的补全声明。 + + 选项: + \t-o option\t为每个 NAME 名称设定补全选项 option + \t-D\t\t为 \default\ 命令补全改变选项 + \t-E\t\t为 \empty\ 命令补全改变选项 + \t-I\t\t为首单词的补全改变选项 + + 使用 `+o' 而不是 `-o' 可以关闭指定的选项。 + + 参数: + + 每个 NAME 名称都对应一个之前以通过 `complete' 内建定义了的补全声明的 + 命令。如果不提供 NAME 名称,当前生成补全的函数必须调用 compopt, + 并且当前执行的补全生成器选项会被修改。 + + 退出状态: + 返回成功,除非使用了无效的选项或者 NAME 名称没有定义补全声明。 + + [mapfile] + 从标准输入读取行到下标数组变量中。 + + 从标准输入读取行到下标数组变量 ARRAY 中,或者如果使用了 -u 选项, + 从文件描述符 FD 中读取。MAPFILE 变量是默认的 ARRAY 变量。 + + 选项: + -d delim\t使用 DELIM 而非换行符断行 + -n count\t最多拷贝 COUNT 行,如果 COUNT 为 0,则拷贝所有行。 + -O origin\t从下标 ORIGIN 开始 赋值给 ARRAY 变量。默认下标是0. + -s count \t丢弃最先读取的 COUNT 行。 + -t\t\t从读取的每行末尾删除一个换行符。 + -u fd\t\t从文件描述符 FD 中读取行而不是标准输入。 + -C callback\t每 QUANTUM 次读行之后对 CALLBACK 回调进行估值。 + -c quantum\t定义每次调用 CALLBACK 回调之间读取的行数。 + + 参数: + ARRAY\t\t存储数据使用的数组变量 + + 如果使用了 -C 而没有 -c,默认的量子是5000。当对 CALLBACK 估值时, + 下一个将被赋值的数组元素的下标作为额外参数被传递。 + + 如果没有显式指定起始下标,mapfile 将在赋值前清空 ARRAY 变量。 + + 退出状态: + 返回成功,除非使用了无效的选项,或者 ARRAY 变量只读或不是下标数组。 + + [readarray] 从一个文件中读取行到数组变量中。 + 一个 `mapfile'的同义词。 + + [unset] 取消设定 shell 变量和函数的值和属性。 + 对每一个 NAME 名称,删除对应的变量或函数。 + + 选项: + -f\t将每个 NAME 视为函数 + -v\t将每个 NAME 视为变量 + -n\t将每个 NAME 视为名称引用,只取消其本身而非其指向的变量 + + 不带选项时,unset 首先尝试取消设定一个变量,如果失败,再尝试取消设定一个 + 函数。 + + 某些变量不可以被取消设定;参见 `readonly'。 + + 退出状态: + 返回成功,除非使用了无效的选项或者 NAME 名称为只读。 + + [local] 记住或显示程序位置。 + + 确定并记住每一个给定 NAME 名称的命令的完整路径。 + 如果不提供参数,则显示已经记住的命令的信息。 + + 选项: + -d 忘记每一个已经记住的 NAME 的位置 + -l 以可作为输入重用的格式显示 + -p pathname 使用 pathname 路径作为 NAME 命令的全路径 + -r 忘记所有记住的位置 + -t 打印记住的每一个 NAME 名称的位置,如果指定了多个 + NAME 名称,则每个位置前面会加上相应的 NAME 名称 + + 参数: + NAME 每个 NAME 名称会在 $PATH 路径变量中被搜索,并且添加到记住的命 + 令 + 列表中。 + + 退出状态: + 返回成功,除非 NAME 命令没有找到或者使用了无效的选项。 + 返回成功,除非使用了无效的选项或者 NAME 名称为只读。 + + [export] 为 shell 变量设定导出属性。 + + 标记每个 NAME 名称为自动导出到后续命令执行的环境。如果提供了 VALUE + 则导出前将 VALUE 作为赋值。 + + 选项: + -f 指 shell 函数 + -n 删除每个 NAME 名称的导出属性 + -p 显示所有导出的变量和函数的列表 + + `--' 的参数禁用进一步的选项处理。 + + 退出状态: + 返回成功,除非使用了无效的选项或者 NAME 名称。 + + [readonly] 标记 shell 变量为不可改变。 + + 标记每一个 NAME 名称为只读;这些 NAME 变量的值将不可以被后续的赋值 + 操作所改变。如果提供了 VALUE,则在标记为只读之前将 VALUE 值赋给变量。 + + 选项: + -a 指下标数组变量 + -A 指关联数组标量 + -f 指 shell 函数 + -p 显示只读变量或函数列表,取决于是否提供了 -f 选项 + + `--' 的参数禁用进一步的选项处理。 + + 退出状态: + 返回成功,除非使用了无效的选项或者 NAME 名称。 + + + [function] 定义 shell 函数。 + + 创建一个以 NAME 为名的 shell 函数。当作为一个简单的命令启用时, + NAME 函数执行调用 shell 的上下文中的 COMMANDs 命令。当 NAME + 被启用时,参数作为 $1...$n 被传递给函数,函数的名字储存在变量 + $FUNCNAME 中。 + + 退出状态: + 返回成功除非 NAME 为只读。 + + + [typeset] 设置变量的值和属性。 + + `declare' 的等价形式。参见 `help declare'。 + + + [source] 在当前 shell 中执行一个文件中的命令。 + + 在当前 shell 中读取并执行 FILENAME 文件中的命令。$PATH 变量中的 + 条目被用于寻找包含 FILENAME 文件的目录。如果提供了任何的 ARGUMENTS + 参数,则它们将成为 FILENAME 文件执行时的位置参数。 + + 退出状态: + 返回 FILENAME 文件中最后一个命令的状态;如果 FILENAME 文件不可读则失败。 + + [bind] 设定 Readline 键绑定和变量。 + + 绑定一个键序列到一个 Readline 函数或者宏,或者设定一个 + Readline 变量。非选项参数的语法和 ~/.inputrc 文件中的等 + 同,但是必须作为一个参数被传递, + 例如,bind '\\\C-x\\C-r\: re-read-init-file'. + + 选项: + -m 键映射 在此命令执行过程中使用指定的键映射。 + 可被接受的键映射名字有 emacs、emacs-standard、emacs- + meta、 + emacs-ctlx、vi、vi-move、vi-command、和 vi-insert。 + -l 列出函数名称。 + -P 列出函数名称和绑定。 + -p 以可以重新用作输入的格式列出函数名称和绑定。 + -S 列出可以启动宏的键序列以及它们的值 + -s 以可以重新用作输入的格式列出可以启动宏的键以及它们的 + 值。 + -V 列出变量名成和它们的值 + -v 以可以重新用作输入的格式列出变量的名称和它们的值 + -q 函数名 查询指定的函数可以由哪些键启动。 + -u 函数名 反绑定所有绑定至指定函数的键。 + -r 键序列 取消指定键序列的绑定。 + -f 文件名 从指定文件中读取键绑定。 + -x 键序列:shell命令\t当指定的键序列被输入时,执行指定的 shell 命令。 + -X 以可被重用的形式列出用 -x 绑定的键序列和命令。 + + 退出状态: + 除非使用了无法辨认的选项或者错误发生,否则返回0. + + [test] 估值算术表达式。 + + 将每个 ARG 参赛作为算术表达式来估值。估值的计算以定宽的整 + 数完成,不带溢出检测,不过除 0 是被置陷阱的并且会报一个错 + 误。下列操作符被按照相同的算术优先级组合。列表的顺序按照 + 优先级从高至低。 + + + \tid++, id--\t变量后置加,后置减 + \t++id, --id\t变量前置加,前置减 + \t-, +\t\t一元减法,一元加法 + \t!, ~\t\t逻辑和位取反 + \t**\t\t指数 + \t*, /, %\t\t乘法,除法,取余数 + \t+, -\t\t增加,减少 + \t<<, >>\t\t向左和向右按位移位 + \t<=, >=, <, >\t比较 + \t==, !=\t\t等于,不等于 + \t&\t\t按位与 + \t^\t\t按位异或 + \t|\t\t按位或 + \t&&\t\t逻辑与 + \t||\t\t逻辑或 + \texpr ? expr : expr + \t\t\t条件操作符 + \t=, *=, /=, %=, + \t+=, -=, <<=, >>=, + \t&=, ^=, |=\t赋值 + + Shell 变量允许作为操作数。表达式中的变量的名称会被取代以值 + (强制转换为定宽的整数)。表达式中的变量不需要打开整数属性。 + + 操作符按照优先级进行估值。括号中的子表达式将被先估值,并可取代上述表达式 + 规则。 + + 退出状态: + 如果最后一个 ARG 参数估值为 0,则 let 返回 1; 否则 let 返回 0。 + +*[other] 显示其他命令帮助信息 . +} + +helpname = { +$cmdName -> +[set] set - 设定或取消设定 shell 选项和位置参数的 +[read] read - 从标准输入读取一行并将其分为不同的域。 +[type] type - 显示命令类型的信息。 +[trap] trap - 对信号和其他事件设陷阱。 +[alias] alias - 定义或显示别名。 +[unalias] unalias - 从别名定义列表中删除每一个“名字”。 +[break] break - 退出 for、while 或 until 循环 +[continue] continue - 继续 for、while 或 until 循环。 +[builtin] builtin - 执行 shell 内建。 +[caller] caller - 返回当前子调用的上下文。 +[cd] cd - 改变 shell 工作目录。 +[pwd] pwd - 打印当前工作目录的名字。 +[true] true - 空的命令。 +[shopt] shopt - 设定和取消设定 shell 选项。 +[false] false - 返回一个不成功的结果。 +[command] command - 执行一个简单命令或者显示命令的相关信息。 +[echo] echo - 将参数写到标准输出。 +[enable] enable - 启用和禁用 shell 内建。 +[getopts] getopts - 解析选项参数。 +[exec] exec - 使用指定命令替换 shell。 +[exit] exit - 退出shell。 +[logout] logout - 退出一个登录 shell. +[fc] fc - 从历史列表中显示或者执行命令。 +[fg] fg - 将任务移至前台。 +[bg] bg - 移动任务至后台。 +[hash] hash - 记住或显示程序位置。 +[help] help - 显示内建命令的相关信息。 +[history] history - 显示或操纵历史列表。 +[jobs] jobs - 显示任务状态。 +[disown] discow - 从当前 shell 中删除任务。 +[kill] kill - 向一个任务发送一个信号。 +[let] let - 估值算术表达式。 +[shift] shift - 移位位置参数。 +[suspend] suspend - 挂起 shell 执行。 +[eval] eval - 对条件表达式进行估值。 +[times] times - 显示进程时间 +[limit] limit - 修改 shell 资源限制。 +[umask] umask - 显示或设定文件模式掩码。 +[return] return - 等待任务完成并返回退出状态。 +[wait] wait - 等待进程完成并且返回退出状态。 +[for] for - 为列表中的每个成员执行命令。 +[select] select - 从列表中选取词并且执行命令。 +[time] time - 报告管道执行的消耗时间。 +[case] case - 基于模式匹配来执行命令。 +[if] if - 根据条件执行命令。 +[while] while - 只要测试成功即执行命令。 +[until] until -当测试不同过时执行命令 +[coproc] corproc - 创建一个以 NAME 为名的副进程。 +[variables] variables - 常用 shell 变量名称和使用。 +[pushd] pushd - 将目录添加到栈中。 +[popd] popd - 从栈中删除目录。 +[dirs] dirs - 显示目录栈。 +[printf] printf -在 FORMAT 的控制下格式化并打印 ARGUMENTS 参数。 +[complete] complete - 指定 Readline 如何补全参数。 +[compgen] compgen - 依据选项显示可能的补全。 +[compopt] compopt - 修改或显示补全选项。 +[mapfile] mapfile - 从标准输入读取行到下标数组变量中。 +[unset] unset - 取消设定 shell 变量和函数的值和属性。 +[readarray] readarry - 从一个文件中读取行到数组变量中。 +[local] local -记住或显示程序位置。 +[export] export -为 shell 变量设定导出属性。 +[readonly] readonly - 标记 shell 变量为不可改变。 +[function] function - 定义 shell 函数。 +[typeset] typeset - 设置变量的值和属性。 +[source] source - 在当前 shell 中执行一个文件中的命令。 +[bind] bind - 设定 Readline 键绑定和变量。 +[test] test - 估值算术表达式。 +*[other] 显示其他命令帮助信息 . +} diff --git a/bash-5.1/resources/zh-HK/message.ftl b/bash-5.1/resources/zh-HK/message.ftl new file mode 100644 index 0000000000000000000000000000000000000000..c6f85a0aec6f8022138fcdf536d16e5ecde43eab --- /dev/null +++ b/bash-5.1/resources/zh-HK/message.ftl @@ -0,0 +1,1341 @@ +helplongdoc ={ +$cmdName -> +[set] + 设定或取消设定 shell 选项和位置参数的 + + 改变 shell 选项和位置参数的值,或者显示 shell 变量的 + 名称和值。 + + 选项: + -a 标记修改的或者创建的变量为导出。 + -b 立即通告任务终结。 + -e 如果一个命令以非零状态退出,则立即退出。 + -f 禁用文件名生成(模式匹配)。 + -h 当查询命令时记住它们的位置 + -k 所有的赋值参数被放在命令的环境中,而不仅仅是 + 命令名称之前的参数。 + -m 启用任务控制。 + -n 读取命令但不执行 + -o 选项名 + 设定与选项名对应的变量: + allexport 与 -a 相同 + braceexpand 与 -B 相同 + emacs 使用 emacs 风格的行编辑界面 + errexit 与 -e 相同 + errtrace 与 -E 相同 + functrace 与 -T 相同 + hashall 与 -h 相同 + histexpand 与 -H 相同 + history 启用命令历史 + ignoreeof shell 读取文件结束符时不会退出 + interactive-comments + 允许在交互式命令中显示注释 + keyword 与 -k 相同 + monitor 与 -m 相同 + noclobber 与 -C 相同 + noexec 与 -n 相同 + noglob 与 -f 相同 + nolog 目前可接受但是被忽略 + notify 与 -b 相同 + nounset 与 -u 相同 + onecmd 与 -t 相同 + physical 与 -P 相同 + pipefail 管道的返回值是最后一个非零返回值的命令的返回结果, + 或者当所有命令都返回零是也为零。 + posix 改变默认时和 Posix 标准不同的 bash 行为 + 以匹配标准 + privileged 与 -p 相同 + verbose 与 -v 相同 + vi 使用 vi 风格的行编辑界面 + xtrace 与 -x 相同 + -p 无论何时当真实的有效的用户身份不匹配时打开。 + 禁用对 $ENV 文件的处理以及导入 shell 函数。 + 关闭此选项会导致有效的用户编号和组编号设定 + 为真实的用户编号和组编号 + -t 读取并执行一个命令之后退出。 + -u 替换时将为设定的变量当作错误对待。 + -v 读取 shell 输入行时将它们打印。 + -x 执行命令时打印它们以及参数。 + -B shell 将执行花括号扩展。 + -C 设定之后禁止以重定向输出的方式覆盖常 + 规文件。 + -E 设定之后 ERR 陷阱会被 shell 函数继承。 + -H 启用 ! 风格的历史替换。当 shell 是交互式的 + 时候这个标识位默认打开。 + -P 设定之后类似 cd 的会改变当前目录的命令不 + 追踪符号链接。 + -T 设定之后 DEBUG 陷阱会被 shell 函数继承。 + -- 任何剩余的参数会被赋值给位置参数。如果没 + 有剩余的参数,位置参数不会被设置。 + - 任何剩余的参数会被赋值给位置参数。 + -x 和 -v 选项已关闭。 + + 使用 + 而不是 - 会使标志位被关闭。标志位也可以在 + shell 被启动时使用。当前的标志位设定可以在 $- 变 + 量中找到。剩余的 ARG 参数是位置参数并且是按照 + $1, $2, .. $n 的顺序被赋值的。如果没有给定 ARG + 参数,则打印所有的 shell 变量。 + + 退出状态: + 返回成功除非使用了无效的参数。 + [read] 从标准输入读取一行并将其分为不同的域。 + + 从标准输入读取单独的一行,或者如果使用了 -u 选项,从文件描述符 FD 中读 + 取。 + 该行被分割成域,如同词语分割一样,并且第一个词被赋值给第一个 NAME 变量, + 第二 + 个词被赋值给第二个 NAME 变量,如此继续,直到剩下所有的词被赋值给最后一个 + NAME + 变量。只有 $IFS 变量中的字符被认作是词语分隔符。 + + 如果没有提供 NAME 变量,则读取的行被存放在 REPLY 变量中。 + + 选项: + -a array\t将词语赋值给 ARRAY 数组变量的序列下标成员,从零开始 + -d delim\t持续读取直到读入 DELIM 变量中的第一个字符,而不是换行符 + -e\t使用 Readline 获取行 + -i text\t使用 TEXT 文本作为 Readline 的初始文字 + -n nchars\t读取 nchars 个字符之后返回,而不是等到读取换行符。 + \t\t但是分隔符仍然有效,如果遇到分隔符之前读取了不足 nchars 个字符。 + -N nchars\t在准确读取了 nchars 个字符之后返回,除非遇到文件结束符或者读 + 超时, + \t\t任何的分隔符都被忽略 + -p prompt\t在尝试读取之前输出 PROMPT 提示符并且不带 + \t\t换行符 + -r\t不允许反斜杠转义任何字符 + -s\t不回显终端的任何输入 + -t timeout\t如果在 TIMEOUT 秒内没有读取一个完整的行则超时并且返回失 + 败。 + \t\tTMOUT 变量的值是默认的超时时间。TIMEOUT 可以是小数。 + \t\t如果 TIMEOUT 是 0,那么仅当在指定的文件描述符上输入有效的时候, + \t\tread 才返回成功;否则它将立刻返回而不尝试读取任何数据。 + \t\t如果超过了超时时间,则返回状态码大于 128 + -u fd\t从文件描述符 FD 中读取,而不是标准输入 + + 退出状态: + 返回码为零,除非遇到了文件结束符、读超时(且返回码不大于128)、 + 出现了变量赋值错误或者无效的文件描述符作为参数传递给了 -u 选项。 + + [type] 显示命令类型的信息。 + + 对于每一个 NAME 名称,指示如果作为命令它将如何被解释。 + + 选项: + -a\t显示所有包含名称为 NAME 的可执行文件的位置; + \t\t包括别名、内建和函数。仅当 `-p' 选项没有使用时 + -f\t抑制 shell 函数查询 + -P\t为每个 NAME 名称惊醒 PATH 路径搜索,即使它是别名、 + \t\t内建或函数,并且返回将被执行的磁盘上文件的名称。 + -p\t返回将被执行的磁盘上文件的名称,或者当 `type -t NAME' + \t不返回 `file' 时,不返回任何值。 + -t\t返回下列词中的任何一个 `alias'、`keyword'、 + \t`function'、`builtin'、`file' 或者 `',相应地如果 NAME 是 + \t一个别名、shell 保留字、shell 函数、shell 内建、 + \t磁盘文件或没有找到。 + + 参数: + NAME\t将要解析的命令。 + + 退出状态: + 返回成功,除非使用了无效的选项或者 NAME 名称为只读。 + + [trap] 对信号和其他事件设陷阱。 + + 定义一个处理器,在 shell 接收到信号和其他条件下执行。 + + ARG 参数是当 shell 接收到 SIGNAL_SPEC 信号时读取和执行的命令。 + 如果没有指定 ARG 参数 (并且只给出一个 SIGNAL_SPEC 信号) 或者 + ARG 参数为 + `-',每一个指定的参数会被重置为原始值。如果 ARG 参数是一个空串,则每一 + 个 + SIGNAL_SPEC 信号会被 shell 和它启动的命令忽略。 + + 如果一个 SIGNAL_SPEC 信号是 EXIT (0) ,则 ARG 命令会在 shell 退出时被 + 执行。如果一个 SIGNAL_SPEC 信号是 DEBUG,则 ARG命令会在每一个简单命 + 令之前执行。 + + 如果不提供参数,trap 打印列表显示每一个与每一个信号相关联的命令。 + + 选项: + -l\t打印一个信号名称和它们对应的编号的列表 + -p\t打印与每个 SIGNAL_SPEC 信号相关联的陷阱命令 + + 每一个 SIGNAL_SPEC 信号可以是 中的信号名称或者信号编号。 + 信号名称大小写敏感且可以使用 SIG 前缀。信号可用 \kill -信号 $$\ + 发送给 shell。 + + 返回成功,除非使用了无效的选项或者 SIGSPEC。 + + [alias] 定义或显示别名。 + + 不带参数时,`alias' 以可重用的格式 + `alias 名称=值'在标准输出设备上打印别名列表。 + + 否则,对于每个给定值的名称定义一个别名。 + 值末尾的空格会使下一个词被检测作为别名替换展开。 + + 选项: + -p\t以可重用的格式打印所有的已定义的别名 + + 退出状态: + 除非一个没有定义的名字被作为参数提供,否则 alias + 返回值为真。 + + [unalias] 从别名定义列表中删除每一个“名字”。 + + 选项: + -a\t删除所有的别名定义 + + 返回成功,除非“名字”不是一个已存在的别名。 + + [break] 退出 for、while 或 until 循环 + + 退出一个 FOR、WHILE 或 UNTIL 循环。如果指定了N,则跳出N重 + 循环 + + 退出状态: + 退出状态为0除非 N 不大于或等于 1。 + + [continue] 继续 for、while 或 until 循环。 + + 继续当前 FOR、WHILE 或 UNTIL 循环的下一步。 + 如果指定了 N, 则继续当前的第 N 重循环。 + + 退出状态: + 退出状态为 0 除非 N 不大于或等于1。 + + [builtin] 执行 shell 内建。 + + 带参数 ARGs 执行 SHELL-BUILTIN 内建,并且不做命令查询 + 在希望以 shell 函数的形式来重新实现 shell 内建, + 并且希望在函数之内执行该 shell 内建的情况下有用处。 + + 退出状态: + 以 SHELL-BUILTIN 内建的退出状态为准,或者如果 SHELL-BUILTIN 不是一个 + shell 内建时为假。 + + [caller] 返回当前子调用的上下文。 + + 不带有 EXPR 时,返回 \$line $filename\。带有 EXPR 时,返回 + \$line $subroutine $filename\;这个额外的信息可以被用于提供 + 栈追踪。 + + EXPR 的值 显示了到当前调用帧需要回去多少个调用帧;顶部帧 + 是第 0 帧。 + + 退出状态: + 除非 shell 不在执行一个 shell 函数或者 EXPR 无效,否则返回结 + 果为0。 + + [cd]改变 shell 工作目录。 + + 改变当前目录至 DIR 目录。默认的 DIR 目录是 shell 变量 HOME + 的值。 + + 变量 CDPATH 定义了含有 DIR 的目录的搜索路径,其中不同的目录名称由冒号 (:) + 分隔。 + 一个空的目录名称表示当前目录。如果要切换到的 DIR 由斜杠 (/) 开头,则 + CDPATH + 不会用上变量。 + + 如果路径找不到,并且 shell 选项 `cdable_vars' 被设定,则参数词被假定为一 + 个 + 变量名。如果该变量有值,则它的值被当作 DIR 目录。 + + 选项: + -L\t强制跟随符号链接: 在处理 `..' 之后解析 DIR 中的符号链接。 + -P\t使用物理目录结构而不跟随符号链接: 在处理 `..' 之前解析 DIR 中的符 + 号链接。 + -e\t如果使用了 -P 参数,但不能成功确定当前工作目录时,返回非零的返回 + 值。 + -@\t在支持拓展属性的系统上,将一个有这些属性的文件当作有文件属性的目 + 录。 + + 默认情况下跟随符号链接,如同指定 `-L'。 + `..' 使用移除向前相邻目录名成员直到 DIR 开始或一个斜杠的方式处理。 + + 退出状态: + 如果目录改变,或在使用 -P 选项时 $PWD 修改成功时返回 0,否则非零。 + + [pwd]打印当前工作目录的名字。 + + 选项: + -L\t打印 $PWD 变量的值,如果它包含了当前的工作目录 + -P\t打印当前的物理路径,不带有任何的符号链接 + + 默认情况下,`pwd' 的行为和带 `-L' 选项一致 + + 退出状态: + 除非使用了无效选项或者当前目录不可读,否则返回状态为0。 + + [true]空的命令。 + + 没有效果; 此命令不做任何操作。 + + 退出状态: + 总是成功。 + [shopt] 设定和取消设定 shell 选项。 + + 改变每个 shell 选项 OPTNAME 的设定。不带参数时, + 列出每个提供的 OPTNAME,否则列出所有 shell 选项; + 同时标注每一个选项是否被设定。 + + 选项: + -o\t限制 OPTNAME 为定义用于`set -o' 的选项 + -p\t打印每个 shell 选项并标注它的状态。 + -q\t抑制输出 + -s\t启用(设定)每个 OPTNAME 选项 + -u\t禁用(取消设定)每个 OPTNAME 选项 + + 退出状态: + 如果 OPTNAME 选项被启用则返回成功;如果是 + 无效的选项或 OPTNAME 被禁用则失败。 + + [false] 返回一个不成功的结果。 + + 退出状态: + 总是失败。 + + [command] 执行一个简单命令或者显示命令的相关信息。 + + 带 ARGS 参数运行 COMMAND 命令且抑制 shell 函数查询,或显示 + 指定的 COMMAND 命令的信息。可以在存在相同名称的函数定义的 + 情况下用于启动磁盘上的命令。 + + 选项: + -p\t使用 PATH 变量的一个默认值以确保所有的标准工具都能被找到。 + -v\t打印 COMMAND 命令的描述,和 `type' 内建相似 + -V\t打印每个 COMMAND 命令的详细描述 + + 退出状态 + 返回 COMMAND 命令的返回状态,或者当找不到 COMMAND 命令时失败。 + + [echo] 将参数写到标准输出。 + + 在标准输出上,显示用空格分割的 ARG 参数后跟一个换行。 + + 选项: + -n\t不要追加换行 + -e\t启用下列反斜杠转义的解释 + -E\t显式地抑制对于反斜杠转义的解释 + + `echo' 对下列反斜杠字符进行转义: + \a\t警告(响铃) + \\b\t退格 + \\c\t抑制更多的输出 + \\e\t转义字符 + \\f\t换页字符 + \\t换行 + \\r\t回车 + \\t\t横向制表符 + \\v\t纵向制表符 + \\\\\t反斜杠 + \\0nnn\t以 NNN(八进制)为 ASCII 码的字符。NNN 可以是 0 到 3 个八进制 + 位 + \\xHH\t以 HH(十六进制)为值的八比特字符。HH 可以是一个或两个十六进制 + 位 + \\uHHHH\t以 HHHH(十六进制)为值的 Unicode 字符。HHHH 可以是一个到 + \t\t四个十六进制位。 + \\UHHHHHHHH 以 HHHHHHHH(十六进制)为值的 Unicode 字符。 + \t\tHHHHHHHH 可以是一到八个十六进制位。 + + 退出状态: + 返回成功除非有写错误发生。 + + 写参数至标准输出设备。 + + 在标准输出设备上显示 ARGs 参数和一个换行。 + + 选项: + -n\t不附加换行 + + 退出状态: + 除非写错误发生,否则返回成功。 + + [enable] 启用和禁用 shell 内建。 + + 启用和禁用 shell 的内建命令。禁用使您能够执行一个和内建 + 命令同名的磁盘上的命令,而无须使用完整的路径名。 + + + 选项: + -a\t打印一个内建的列表,并显示其中每一个是否启用 + -n\t禁用每一个 NAME 内建或者显示一个被禁用的内建的列表 + -p\t以可重用的格式打印一个内建的列表 + -s\t仅打印Posix `special' 内建的名称 + + 控制动态加载的选项: + -f\t从共享对象 FILENAME 文件中加载 NAME 内建 + -d\t删除以 -f 选项加载的内建 + + 不带选项时,每一个 NAME 内建都被启用。 + + 如果要使用 $PATH 中找到的 `test' 而不是 shell 内建的版本, + 输入 `enable -n test'。 + + 退出状态: + 返回成功,除非 NAME 不是一个 shell 内建或者有错误发生。 + + [getopts] 解析选项参数。 + + getopts 被 shell 过程用于解析可定位的参数作为选项。 + + + OPTSTRING 字符串包含待识别的选项字母;如果一个字母后面跟 + 着分号,则该选项需要一个参数,而该参数应用空格与选项分开。 + + + 每次启动时,getopts 会将下一个选项放到 shell 变量 $name + 中,如果 name 变量不存在则先将其初始化,而下一个待处 + 理的参数序号放入 shell 变量 OPTIND 中。OPTIND 变量在每 + 次 shell 或者 shell 脚本启动时都被初始化为1。当一个选项要 + 求有一个参数时,getopts 将参数放入 shell 变量 OPTARG + 中。 + + getopts 有两种报告错误的方法。如果 OPTSTRING 变量的第 + 一个字符是冒号,getopts 使用沉默错误报告。在这种模式 + 下,不会打印错误消息。如果看到了一个无效的选项, + getopts 将找到的选项字符放至 OPTARG 变量中。如果一个必 + 须的选项没有找到,getopts 放一个 ':' 到 NAME 变量中并且设 + 置 OPTARG 变量为找到的选项字符。如果 getopts 不在沉默模 + 式中,并且遇到了一个无效的选项,getopts 放置一个 '?' 到 NAME + 变量中并且取消设定 OPTARG变量。如果必须的选项没有找到, + 一个'?'会被放入 NAME变量中,OPTARG 将被取消设定,并且会 + 打印一个诊断信息。 + + 如果 shell 变量 OPTERR 的值为0,getopts 禁用 + 错误信息的打印,即使 OPTSTRING 变量的第一个字符不是一 + 个冒号。OPTERR 的默认值为1. + + getopts 通常解析可定位的参数($0 - $9),不过如果提供了 + 更多的参数,它们反而会被解析。 + + 退出状态: + 如果一个选项被找到则返回成功;如果遇到了选项的结尾或者 + 有错误发生则返回失败。 + + [exec] 使用指定命令替换 shell。 + + 执行 COMMAND 命令,以指定的程序替换这个 shell。 + ARGUMENTS 参数成为 COMMAND命令的参数。如果 + 没有指定COMMAND 命令,则任何的重定向在当前 shell 中生效。 + + 选项: + -a 名称\t作为第0个参数传递给 COMMAND 命令 + -c\t\t在一个空环境中执行 COMMAND 命令 + -l\t\t在COMMAND 命令的第0个参数中加一个短线 + + 如果命令不能被执行,则退出一个非交互式的 shell,除非 + shell 选项`execfail' 已经设定。 + + 退出状态: + 返回成功除非 COMMAND 命令没有找到或者出现一个重定向错误。 + + [exit] 退出shell。 + + 以状态 N 退出 shell。 如果 N 被省略,则退出状态 + 为最后一个执行的命令的退出状态。 + + [logout] 退出一个登录 shell. + + 以状态 N 退出一个登录 shell。如果不在登录 shell 中执行,则 + 返回一个错误。 + + [fc] 从历史列表中显示或者执行命令。 + + fc 被用于从历史列表中列出或者重新编辑并执行命令。 + FIRST 和 LAST 变量可以是数字用于指定范围,或者 FIRST 可以是 + 字符串,意味着以这个字符串打头的最近的一个命令。 + + + 选项: + -e ENAME\t选择使用哪个编辑器。默认的是 FCEDIT, 然后是 EDITOR, + \t\t然后是 vi + -l \t列出行而不编辑 + -n\t列举时省略行号 + -r\t反转行的顺序(最新行在前) + + 用 `fc -s [模式=替换 ...] [命令]' 的格式,COMMAND 命令会在 OLD=NEW + 替换之后被重新执行。 + + r='fc -s' 是一个有用的别名,这样的话输入 `r cc'会执行最后一个以 `cc' + 开头的命令,输入 `r'会重新执行最后一个命令。 + + + 退出状态: + 返回成功,或者执行的命令的状态;如果错误发生则返回非零。 + + [fg] 将任务移至前台。 + + 将以 JOB_SPEC 标识的任务放至前台,使其成为 + 当前任务。如果 JOB_SPEC 不存在,shell 观念中的当前任务 + 将被使用。 + + 退出状态: + 放至前台的命令状态,或者当错误发生时为失败。 + + [bg] 移动任务至后台。 + + 将 JOB_SPEC 标识的任务放至后台,就像它们 + 是带 `&' 启动的一样。如果 JOB_SPEC 不存在,shell 观念中的 + 当前任务将会被使用。 + + 退出状态: + 返回成功除非任务管理没有启用或者错误发生。 + + [hash] 记住或显示程序位置。 + + 确定并记住每一个给定 NAME 名称的命令的完整路径。 + 如果不提供参数,则显示已经记住的命令的信息。 + + 选项: + -d\t\t忘记每一个已经记住的 NAME 的位置 + -l\t\t以可作为输入重用的格式显示 + -p pathname\t使用 pathname 路径作为 NAME 命令的全路径 + -r\t\t忘记所有记住的位置 + -t\t\t打印记住的每一个 NAME 名称的位置,如果指定了多个 + \t\tNAME 名称,则每个位置前面会加上相应的 NAME 名称 + \t\t + 参数: + NAME\t\t每个 NAME 名称会在 $PATH 路径变量中被搜索,并且添加到记住的命 + 令 + 列表中。 + + 退出状态: + 返回成功,除非 NAME 命令没有找到或者使用了无效的选项。 + + [help] 显示内建命令的相关信息。 + + 显示内建命令的简略信息。如果指定了 PATTERN 模式, + 给出所有匹配 PATTERN 模式的命令的详细帮助,否则打 + 印一个帮助主题列表 + + 选项: + -d\t输出每个主题的简短描述 + -m\t以伪 man 手册的格式显示使用方法 + -s\t为每一个匹配 PATTERN 模式的主题仅显示一个用法 + \t简介 + + 参数: + PATTERN\t指定帮助主题的模式 + + 退出状态: + 返回成功,除非未找到 PATTERN 模式没有找到或者使用了无效选项。 + + [history] 显示或操纵历史列表。 + + 带行号显示历史列表,将每个被修改的条目加上 `*' 前缀。 + 参数 N 会仅列出最后的 N 个条目。 + + 选项: + -c\t删除所有条目从而清空历史列表。 + -d 偏移量\t从指定位置删除历史列表。负偏移量将从历史条目末尾 + \t\t开始计数 + + -a\t将当前会话的历史行追加到历史文件中 + -n\t从历史文件中读取所有未被读取的行 + \t\t并且将它们附加到历史列表 + -r\t读取历史文件并将内容追加到历史列表中 + -w\t将当前历史写入到历史文件中 + + -p\t对每一个 ARG 参数展开历史并显示结果,而不存储到历史列表中 + -s\t以单条记录追加 ARG 到历史列表中 + + 如果给定了 FILENAME 文件名,则它将被作为历史文件。否则 + 如果 $HISTFILE 变量有值的话使用之,不然使用 ~/.bash_history 文件。 + + 如果 $HISTTIMEFORMAT 变量被设定并且不为空,它的值会被用于 + strftime(3) 的格式字符串来打印与每一个显示的历史条目想关联的 + 时间戳,否则不打印时间戳。 + + 退出状态: + 返回成功,除非使用了无效的选项或者发生错误。 + [jobs] 显示任务状态。 + + 列出活动的任务。JOBSPEC 限制仅输出指定的任务。 + 不带选项时,所有活动任务的状态都会显示。 + + 选项: + -l\t在正常信息基础上列出进程号 + -n\t仅列出上次通告之后改变了状态的进程 + -p\t仅列出进程号 + -r\t限制仅输出运行中的任务 + -s\t限制仅输出停止的任务 + + 如果使用了 -x 选项,ARG 参数中的所有任务声明会被替换为该任务 + 的进程组头领的进程号,然后执行 COMMAND 命令。 + + 退出状态: + 返回成功,除非使用了无效的选项或者有错误发生。 + 如果使用 -x 选项,则返回 COMMAND 命令的退出状态。 + + [disown] 从当前 shell 中删除任务。 + + 从活动任务表中删除每一个 JOBSPEC 参数。不带任何 + JOBSPEC 参数时,shell 使用观念中的当前任务。 + + 选项: + -a\t如果不提供 JOBSPEC 参数,则删除所有任务 + -h\t标识每个 JOBSPEC 任务,从而当 shell 接收到 SIGHUP + \t\t信号时不发送 SIGHUP 给指定任务 + -r\t仅删除运行中的任务 + + 退出状态: + 返回成功除非使用了无效的选项或者 JOBSPEC 声明。 + + [kill] 向一个任务发送一个信号。 + + 向以 PID 进程号或者 JOBSPEC 任务声明指定的进程发送一个以 + SIGSPEC 信号声明或 SIGNUM 信号编号命名的信号。如果没有指定 + SIGSPEC 或 SIGNUM,那么假定发送 SIGTERM 信号。 + + 选项: + -s sig\tSIG 是信号名称 + -n sig\tSIG 是信号编号 + -l\t列出信号名称;如果参数后跟 `-l'则被假设为信号编号, + \t\t而相应的信号名称会被列出 + + Kill 成为 shell 内建有两个理由:它允许使用任务编号而不是进程号, + 并且在可以创建的进程数上限达到是允许进程被杀死。 + + 退出状态: + 返回成功,除非使用了无效的选项或者有错误发生。 + + [let] 估值算术表达式。 + + 将每个 ARG 参赛作为算术表达式来估值。估值的计算以定宽的整 + 数完成,不带溢出检测,不过除 0 是被置陷阱的并且会报一个错 + 误。下列操作符被按照相同的算术优先级组合。列表的顺序按照 + 优先级从高至低。 + + + \tid++, id--\t变量后置加,后置减 + \t++id, --id\t变量前置加,前置减 + \t-, +\t\t一元减法,一元加法 + \t!, ~\t\t逻辑和位取反 + \t**\t\t指数 + \t*, /, %\t\t乘法,除法,取余数 + \t+, -\t\t增加,减少 + \t<<, >>\t\t向左和向右按位移位 + \t<=, >=, <, >\t比较 + \t==, !=\t\t等于,不等于 + \t&\t\t按位与 + \t^\t\t按位异或 + \t|\t\t按位或 + \t&&\t\t逻辑与 + \t||\t\t逻辑或 + \texpr ? expr : expr + \t\t\t条件操作符 + \t=, *=, /=, %=, + \t+=, -=, <<=, >>=, + \t&=, ^=, |=\t赋值 + + Shell 变量允许作为操作数。表达式中的变量的名称会被取代以值 + (强制转换为定宽的整数)。表达式中的变量不需要打开整数属性。 + + 操作符按照优先级进行估值。括号中的子表达式将被先估值,并可取代上述表达式 + 规则。 + + [shift] 移位位置参数。 + + 重命名位置参数 $N+1、$N+2 ... 到 $1、$2 ... 如果没有给定 N, + 则假设为1. + + 退出状态: + 返回成功,除非 N 为负或者大于 $#。 + 返回 N,或者如果 shell 不在执行一个函数或引用脚本时,失败。 + + [suspend] 挂起 shell 执行。 + + 挂起 shell 的执行直到收到 SIGCONT 信号。 + 登录 shell 不可以被挂起,除非强制执行。 + + 选项: + -f\t强制挂起,即使是登录 shell。 + + 退出状态: + 返回成功,除非没有启用任务控制或者有错误发生。 + + [eval] 对条件表达式进行估值。 + + 根据 EXPR 表达式的估值以状态 0 (真) 或 1 (伪) 退出。 + 表达式可以是一元或者二元的。一元表达式通常用于检测 + 文件状态。同时还有字符串操作符和数字比较操作符。 + + 文件操作符: + + -a 文件 如果文件存在则为真。 + -b 文件 如果文件为块特殊文件则为真。 + -c 文件 如果文件为字符特殊文件则为真。 + -d 文件 如果文件为目录则为真。 + -e 文件 如果文件存在则为真。 + -f 文件 如果文件存在且为常规文件则为真。 + -g 文件 如果文件的组属性设置打开则为真。 + -h 文件 如果文件为符号链接则为真。 + -L 文件 如果文件为符号链接则为真。 + -k 文件 如果文件的粘滞 (sticky) 位设定则为真。 + -p 文件 如果文件为命名管道则为真。 + -r 文件 如果文件对于您是可读的则为真。 + -s 文件 如果文件存在且不为空则为真。 + -S 文件 如果文件是套接字则为真。 + -t 文件描述符 如果文件描述符在一个终端上打开则为真。 + -u 文件 如果文件的用户数行设置打开则为真。 + -w 文件 如果文件对您是可写的则为真 + -x 文件 如果文件对您是可执行的则为真。 + -O 文件 如果文件是被您所有的则为真。 + -G 文件 如果文件被您的组所有则为真。 + -N 文件 如果文件上次被读取之后修改过则为真。 + + FILE1 -nt FILE2 如果 file1 文件新于 file2 文件则为真(根据 + 修改日期)。 + + FILE1 -ot FILE2 如果 file1 文件旧于 file2 文件则为真。 + + FILE1 -ef FILE2 如果 file1 文件是 file2 文件的硬链接则为真。 + + 字符串操作符 + + -z 字符串 如果字符串为空则为真。 + + -n 字符串 + 字符串 如果字符串不为空则为真。 + + STRING1 = STRING2 + 如果 string1 和 string2 字符串相同则为真。 + STRING1 != STRING2 + 如果 string1 和 string2 字符串不相同则为真。 + STRING1 < STRING2 + 如果按字典排序 string1 在 string2 串之前则为真。 + STRING1 > STRING2 + 如果按字典排序 string1 在 string2 串之前则为真。 + + 其他操作符: + + -o 选项 如果指定 shell 选项启用则为真。 + -v VAR 如果指定 Shell 变量 VAR 已赋值则为真。 + -R VAR 如果指定 Shell 变量 VAR 已赋值且为名称引用则为真。 + ! EXPR 如果表达式 expr 为假则为真。 + EXPR1 -a EXPR2 如果 expr1 和 expr2 都为真则为真。 + EXPR1 -o EXPR2 如果 expr1 和 expr2 有一个为真则为真。 + + arg1 OP arg2 算术测试。OP操作符可以是 -eq、-ne、 + -lt、-le、-gt、或 -ge 中的一个。 + + 二元算术操作返回真,如果 ARG1 参数等于、不等于、 + 小于、小于等于、大于、或者大于等于 ARG2 参数。 + + 退出状态: + 如果 EXPR 表达式估值为真则返回成功;如果 EXPR 表达式估值 + 为假或者使用了无效的参数则返回失败。 + + [times] 显示进程时间 + + 打印 shell 及其所有子进程的累计用户空间和 + 系统空间执行时间。 + + 退出状态 + 总是成功。 + + [limit] 修改 shell 资源限制。 + + 在允许此类控制的系统上,提供对于 shell 及其创建的进程所可用的 + 资源的控制。 + + 选项: + -S\t使用软 (`soft') 资源限制 + -H\t使用硬 (`hard') 资源限制 + -a\t所有当前限制都被报告 + -b\t套接字缓存尺寸 + -c\t创建的核文件的最大尺寸 + -d\t一个进程的数据区的最大尺寸 + -e\t最高的调度优先级 (`nice') + -f\t有 shell 及其子进程可以写的最大文件尺寸 + -i\t最多的可以挂起的信号数 + -k\t分配给此进程的最大 kqueue 数量 + -l\t一个进程可以锁定的最大内存尺寸 + -m\t最大的内存进驻尺寸 + -n\t最多的打开的文件描述符个数 + -p\t管道缓冲区尺寸 + -q\tPOSIX 信息队列的最大字节数 + -r\t实时调度的最大优先级 + -s\t最大栈尺寸 + -t\t最大的CPU时间,以秒为单位 + -u\t最大用户进程数 + -v\t虚拟内存尺寸 + -x\t最大的文件锁数量 + -P\t最大伪终端数量 + -T\t最大线程数量 + + 并非所有选项在所有系统上可用。 + + 如果提供了 LIMIT 变量,则它为指定资源的新的值;特别的 LIMIT 值为 + `soft'、`hard'和`unlimited',分别表示当前的软限制,硬限制和无限制。 + 否则打印指定资源的当前限制值,不带选项则假定为 -f + + 取值都是 1024 字节为单位,除了 -t 以秒为单位,-p 以 512 字节递增, + -u 为无范围的进程数量。 + + 退出状态: + 返回成功,除非使用了无效的选项或者错误发生。 + + [umask] 显示或设定文件模式掩码。 + + 设定用户文件创建掩码为 MODE 模式。如果省略了 MODE,则 + 打印当前掩码的值。 + + 如果 MODE 模式以数字开头,则被当作八进制数解析;否则是一个 + chmod(1) 可接收的符号模式串。 + + 选项: + -p\t如果省略 MODE 模式,以可重用为输入的格式输入 + -S\t以符号形式输出,否则以八进制数格式输出 + + 退出状态: + 返回成功,除非使用了无效的 MODE 模式或者选项。 + + [return] 等待任务完成并返回退出状态。 + + 等待以 ID 编号识别的进程,其中 ID 可以是进程编号或者任务声明, + 并报告它的终止状态。如果 ID 没有给出,则等待所有的当前活跃子 + 进程,并且返回状态为零。如果 ID 是任务声明,等待任务管道中的 + 所有进程。 + + 若给定了 -n 选项,等待下一个任务完成并返回其状态。 + + 若给定了 -f 选项,且已启用了任务控制,则等待指定的 ID 终止 + 而非等待它改变状态。 + 退出状态: + 返回最后一个 ID 进程的状态;如果使用了无效的 ID 或者选项则失败。 + + [wait] 等待进程完成并且返回退出状态。 + + 等待指定进程并报告它的终止状态。如果没有提供 PID,则当前所有的活跃 + 子进程都会被等待,并且返回码为零。PID 必须为进程号。 + + 退出状态: + 返回进程 ID 的状态;如果 PID 是无效的进程号或者指定了无效的选项则失败。 + + [for] 为列表中的每个成员执行命令。 + + “for”循环为列表中的每个成员执行一系列的命令。如果没有 + “in <词语> ...;”则假定使用“in \$@\”。对于 <词语> 中的每 + 个元素,<名称> 变量被设定为该元素后执行 <命令>。 + + 退出状态: + 返回最后执行的命令的状态。 + + [select] 从列表中选取词并且执行命令。 + + <词语...> 被展开,生成一个词的列表。展开的词集合被打印 + 在标准错误输出设备上,每个以一个数字做前缀。如果没有 `in WORDS' + 则假定使用`in \$@\'。PS3提示符会被显示并且从标准输入读入一行 + 如果该行由被显示的词对应的数字组成,则 NAME 变量被设定为相应 + 的词。如果行为空,则 WORDS 变量和提示符被重新显示。如果读取了 + 文件结束符,则命令完成。读入任何其他的值会导致 NAME 变量被设定 + 为空。读入的行被存放在变量 REPLY 中。COMMANDS 命令在每次选择 + 之后执行直到执行一个 break 命令。 + + 退出状态: + 返回最后一个执行的命令的状态。 + + [time] 报告管道执行的消耗时间。 + + 执行 PIPELINE 并且打印 PIPELINE 终结时实际时间、用户 CPU 时间和系统 + CPU 时间的总结。 + + 选项: + -p\t用可迁移的 POSIX 格式打印用时总结。 + + TIMEFORMAT 变量的值被作为输出格式。 + + 退出状态: + 返回状态即PIPELINE 的返回状态。 + + [case] 基于模式匹配来执行命令。 + + 基于 PATTERN 模式匹配的词 WORD,有选择的执行 COMMANDS 命令。 + `|' 用于分隔多个模式。 + + 退出状态: + 返回最后一个执行的命令的状态。 + + [if] 根据条件执行命令。 + + `if COMMANDS'列表被执行。如果退出状态为零,则执行`then COMMANDS' + 列表。否则按顺序执行每个 `elif COMMANDS'列表,并且如果它的退出状态为 + 零,则执行对应的 `then COMMANDS' 列表并且 if 命令终止。否则如果存在的 + 情况下,执行 `else COMMANDS'列表。整个结构的退出状态是最后一个执行 + 的命令的状态,或者如果没有条件测试为真的话,为零。 + + 退出状态: + 返回最后一个执行的命令的状态。 + + [while] 只要测试成功即执行命令。 + + 只要在 `while' COMMANDS 中的最终命令返回结果为0,则 + 展开并执行 COMMANDS 命令。 + + 退出状态: + 返回最后一个执行的命令的状态。 + + [until] 当测试不同过时执行命令。 + + `until' COMMANDS 命令的最终命令返回状态不为 0 时, + 展开并执行 COMMANDS 命令。 + + 退出状态: + 返回最后一个执行的命令的状态。 + + [coproc] 创建一个以 NAME 为名的副进程。 + + 异步执行 COMMANDS 命令,在执行 shell 中的数组变量 NAME + 的 0 号和 1 号元素作为文件描述符,以一个管道连接命令 + 分别作为命令的标准输出和输入设备。 + 默认的 NAME 是 \COPROC\。 + + 退出状态: + 副进程会返回退出状态 0。 + + [variables] 常用 shell 变量名称和使用。 + + BASH_VERSION\t当前 Bash 的版本信息。 + CDPATH\t用于 `cd' 命令参数搜索的分号分隔的目录列表 + GLOBIGNORE\t路径扩展时忽略的文件名匹配模式列表, + \t\t以分号分隔。 + HISTFILE\t您的命令历史存放的文件名称。 + HISTFILESIZE\t历史文件最多可以保存的行数。 + HISTSIZE\t一个运行的 shell 最多可以访问的历史命令行数。 + HOME\t您的登录目录的完整路径。 + HOSTNAME\t当前主机的主机名。 + HOSTTYPE\t当前版本的 BASH 在其之上运行的 CPU 类型。 + IGNOREEOF\t控制 shell 收到文件结束符作为单一输入后的 + \t\t动作。如果设定这个变量,则它的值是 shell 退出之前在 + \t\t一个空行上可以连续看到的文件结束符数量(默认为10)。 + \t\t未设定时,文件结束符标志着输入的结束。 + MACHTYPE\t描述当前运行 Bash 的系统的字符串。 + MAILCHECK\tBash 检测新邮件的频率,以秒为单位。 + MAILPATH\tBash 从中检测新邮件的文件列表,以分号分隔。 + OSTYPE\t运行 Bash 的 Unix 版本。 + PATH\t当寻找命令时搜索的目录列表,以冒号分隔。 + PROMPT_COMMAND\t打印每一个主提示符之前执行的命 + \t\t令。 + PS1\t\t主提示符字符串。 + PS2\t\t从提示符字符串。 + PWD\t\t当前目录的完整路径。 + SHELLOPTS\t已启用的 shell 选项列表,以冒号分隔。 + TERM\t当前终端类型的名称。 + TIMEFORMAT\t以关键则 `time' 显示的时间统计信息的输出 + \t\t格式。 + auto_resume\t非空时,一个单独的命令词会首先被在当前 + \t\t停止的任务列表中搜索。如果找到则该任务被置于前台。 + \t\t如果值为 `exact' 则意味着命令词必须精确匹配停止任务 + \t\t列表中的命令。如果值为 `substring' 则意味着命令词必 + \t\t须匹配任务的一个子字符串。任何其他的值意味着命令词 + \t\t必须是停止任务的一个前缀。 + histchars\t控制历史展开和快速替换的字符。第一个字符是 + \t\t历史替换字符,通常是 `!'。第二个字符是快速替换字符, + \t\t通常是 `^'。第三个是历史注释字符,通常是 `#'。 + HISTIGNORE\t用于决定哪些命令被存入历史文件的模式 + \t\t列表,以冒号分隔。 + + [pushd] 将目录添加到栈中。 + + 将目录添加到目录栈顶,或着旋转栈直到当前工作目录成为 + 新的栈顶。不带参数时,交换栈顶的两个目录。 + + 选项: + -n\t抑制添加目录至栈时通常的改变目录操作,从而仅对栈 + \t进行操作。 + + 参数: + +N\t旋转栈从而第 N 个目录 (`dirs' 显示的列表中左起,从零开始) + \t将移动到栈顶。 + + -N\t旋转栈从而第 N 个目录 (`dirs' 显示的列表中右起,从零开始) + \t将移动到栈顶。 + + dir\t将 DIR 目录添加到栈顶,并且使其成为当前工作目录。 + + `dirs' 内建显示目录栈。 + + 退出状态: + + [popd] 从栈中删除目录。 + + 从目录栈中删除条目。不带参数时,删除栈顶目录,并改变至新的栈 + 顶目录。 + + 选项: + -n\t抑制从栈中删除目录时通常的目录变换操作,从而仅对栈 + \t进行操作。 + + 参数: + +N\t删除第 N 个目录 (`dirs' 显示的目录列表中左起,从零开始)。 + \t例如:`popd +0' 删除第一个目录,`popd +1' 删除第二个。 + + -N\t删除第 N 个目录 (`dirs' 显示的目录列表中右起,从零开始)。 + \t例如:`popd -0' 删除最后一个目录,,`popd -1' 删除倒数第二个。 + + `dirs' 内建显示目录栈。 + + 退出状态: + 返回成功,除非使用了无效的参数或者目录变换失败。 + + [dirs] 显示目录栈。 + + 显示当前记住的目录列表。通过 `pushd' 命令可以将目录存入列表 + 中;`popd' 命令可用于遍历弹出列表。 + + 选项: + -c\t删除所有元素以清空目录栈 + -l\t不打印与主目录相关的波浪号前缀的目录 + -p\t每行一个条目打印目录栈 + -v\t每行一个条目,以栈中位置为前缀打印目录栈 + + 参数: + +N\t显示 dirs 不带选项启动时显示的目录列表左起中第 + \tN 个目录,从零开始。 + + -N\t显示 dirs 不带选项启动时显示的目录列表右起中第 + \tN 个目录,从零开始。 + + 退出状态: + 返回成功,除非使用了无效的选项或者发生错误。 + + [printf] 在 FORMAT 的控制下格式化并打印 ARGUMENTS 参数。 + + 选项: + -v var\t将输出赋值给 shell 变量 VAR 而不显示在标准输出上 + + FORMAT 是包含三种对象的字符串:简单地被拷贝到标准输出的普通字符; + 被变换之后拷贝到标准输入的转义字符;以及每个都会影响到下个参数的打印的格 + 式化声明。 + + 在 printf(1) 中描述的标准控制声明之外,printf 解析: + + %b\t扩展对应参数中的反斜杠转义序列 + %q\t以可作为 shell 输入的格式引用参数 + %(fmt)T\t以 FMT 为供给 strftime(3) 的格式输出日期时间字符串 + + 退出状态: + 返回成功,除非使用了无效的选项或者写或赋值错误发生。 + + [complete] 指定 Readline 如何补全参数。 + + 声明对于每一个 NAME 名称如何补全参数。如果不带选项, + 现有的补全声明会以可以重用为输入的格式打印出来。 + + 选项: + -p\t以可重用的格式打印现有的补全声明。 + -r\t对于每个 NAME 名称删除补全声明,或者如果没有提供 NAME + \t名称,删除所有的补全声明。 + -D\t对于没有补全声明定义的命令,设定默认的补全动作 + -E\t对于 \empty\ 命令设定补全动作,—— 对于空行的补全。 + -I\t将补全和动作应用在首单词(通常是所给命令)上 + + 尝试补全时,按照上述大写字母选项的顺序进行动作。 + 如果给出了多个选项,-D 选项优先级高于 -E 选项,且 + 这两个选项优先级均高于 -I。 + + 退出状态: + 返回成功,除非使用了无效的选项或者错误发生。 + + [compgen] 依据选项显示可能的补全。 + + 意图在能产生可能的补全的 shell 函数内部使用。 + 如果提供了可选的 WORD 参数,则产生按照 WORD + 进行的匹配。 + + 退出状态: + 除非使用了无效选项或者错误发生,否则返回成功。 + + [compopt] 修改或显示补全选项。 + + 修改每个 NAME 名称的补全选项,或如果没有提供 NAME 名称,执行当前的补 + 全。 + 如果不带选项,打印每个 NAME 名称的补全选项或当前的补全声明。 + + 选项: + \t-o option\t为每个 NAME 名称设定补全选项 option + \t-D\t\t为 \default\ 命令补全改变选项 + \t-E\t\t为 \empty\ 命令补全改变选项 + \t-I\t\t为首单词的补全改变选项 + + 使用 `+o' 而不是 `-o' 可以关闭指定的选项。 + + 参数: + + 每个 NAME 名称都对应一个之前以通过 `complete' 内建定义了的补全声明的 + 命令。如果不提供 NAME 名称,当前生成补全的函数必须调用 compopt, + 并且当前执行的补全生成器选项会被修改。 + + 退出状态: + 返回成功,除非使用了无效的选项或者 NAME 名称没有定义补全声明。 + + [mapfile] + 从标准输入读取行到下标数组变量中。 + + 从标准输入读取行到下标数组变量 ARRAY 中,或者如果使用了 -u 选项, + 从文件描述符 FD 中读取。MAPFILE 变量是默认的 ARRAY 变量。 + + 选项: + -d delim\t使用 DELIM 而非换行符断行 + -n count\t最多拷贝 COUNT 行,如果 COUNT 为 0,则拷贝所有行。 + -O origin\t从下标 ORIGIN 开始 赋值给 ARRAY 变量。默认下标是0. + -s count \t丢弃最先读取的 COUNT 行。 + -t\t\t从读取的每行末尾删除一个换行符。 + -u fd\t\t从文件描述符 FD 中读取行而不是标准输入。 + -C callback\t每 QUANTUM 次读行之后对 CALLBACK 回调进行估值。 + -c quantum\t定义每次调用 CALLBACK 回调之间读取的行数。 + + 参数: + ARRAY\t\t存储数据使用的数组变量 + + 如果使用了 -C 而没有 -c,默认的量子是5000。当对 CALLBACK 估值时, + 下一个将被赋值的数组元素的下标作为额外参数被传递。 + + 如果没有显式指定起始下标,mapfile 将在赋值前清空 ARRAY 变量。 + + 退出状态: + 返回成功,除非使用了无效的选项,或者 ARRAY 变量只读或不是下标数组。 + + [readarray] 从一个文件中读取行到数组变量中。 + 一个 `mapfile'的同义词。 + + [unset] 取消设定 shell 变量和函数的值和属性。 + 对每一个 NAME 名称,删除对应的变量或函数。 + + 选项: + -f\t将每个 NAME 视为函数 + -v\t将每个 NAME 视为变量 + -n\t将每个 NAME 视为名称引用,只取消其本身而非其指向的变量 + + 不带选项时,unset 首先尝试取消设定一个变量,如果失败,再尝试取消设定一个 + 函数。 + + 某些变量不可以被取消设定;参见 `readonly'。 + + 退出状态: + 返回成功,除非使用了无效的选项或者 NAME 名称为只读。 + + [local] 记住或显示程序位置。 + + 确定并记住每一个给定 NAME 名称的命令的完整路径。 + 如果不提供参数,则显示已经记住的命令的信息。 + + 选项: + -d 忘记每一个已经记住的 NAME 的位置 + -l 以可作为输入重用的格式显示 + -p pathname 使用 pathname 路径作为 NAME 命令的全路径 + -r 忘记所有记住的位置 + -t 打印记住的每一个 NAME 名称的位置,如果指定了多个 + NAME 名称,则每个位置前面会加上相应的 NAME 名称 + + 参数: + NAME 每个 NAME 名称会在 $PATH 路径变量中被搜索,并且添加到记住的命 + 令 + 列表中。 + + 退出状态: + 返回成功,除非 NAME 命令没有找到或者使用了无效的选项。 + 返回成功,除非使用了无效的选项或者 NAME 名称为只读。 + + [export] 为 shell 变量设定导出属性。 + + 标记每个 NAME 名称为自动导出到后续命令执行的环境。如果提供了 VALUE + 则导出前将 VALUE 作为赋值。 + + 选项: + -f 指 shell 函数 + -n 删除每个 NAME 名称的导出属性 + -p 显示所有导出的变量和函数的列表 + + `--' 的参数禁用进一步的选项处理。 + + 退出状态: + 返回成功,除非使用了无效的选项或者 NAME 名称。 + + [readonly] 标记 shell 变量为不可改变。 + + 标记每一个 NAME 名称为只读;这些 NAME 变量的值将不可以被后续的赋值 + 操作所改变。如果提供了 VALUE,则在标记为只读之前将 VALUE 值赋给变量。 + + 选项: + -a 指下标数组变量 + -A 指关联数组标量 + -f 指 shell 函数 + -p 显示只读变量或函数列表,取决于是否提供了 -f 选项 + + `--' 的参数禁用进一步的选项处理。 + + 退出状态: + 返回成功,除非使用了无效的选项或者 NAME 名称。 + + + [function] 定义 shell 函数。 + + 创建一个以 NAME 为名的 shell 函数。当作为一个简单的命令启用时, + NAME 函数执行调用 shell 的上下文中的 COMMANDs 命令。当 NAME + 被启用时,参数作为 $1...$n 被传递给函数,函数的名字储存在变量 + $FUNCNAME 中。 + + 退出状态: + 返回成功除非 NAME 为只读。 + + + [typeset] 设置变量的值和属性。 + + `declare' 的等价形式。参见 `help declare'。 + + + [source] 在当前 shell 中执行一个文件中的命令。 + + 在当前 shell 中读取并执行 FILENAME 文件中的命令。$PATH 变量中的 + 条目被用于寻找包含 FILENAME 文件的目录。如果提供了任何的 ARGUMENTS + 参数,则它们将成为 FILENAME 文件执行时的位置参数。 + + 退出状态: + 返回 FILENAME 文件中最后一个命令的状态;如果 FILENAME 文件不可读则失败。 + + [bind] 设定 Readline 键绑定和变量。 + + 绑定一个键序列到一个 Readline 函数或者宏,或者设定一个 + Readline 变量。非选项参数的语法和 ~/.inputrc 文件中的等 + 同,但是必须作为一个参数被传递, + 例如,bind '\\\C-x\\C-r\: re-read-init-file'. + + 选项: + -m 键映射 在此命令执行过程中使用指定的键映射。 + 可被接受的键映射名字有 emacs、emacs-standard、emacs- + meta、 + emacs-ctlx、vi、vi-move、vi-command、和 vi-insert。 + -l 列出函数名称。 + -P 列出函数名称和绑定。 + -p 以可以重新用作输入的格式列出函数名称和绑定。 + -S 列出可以启动宏的键序列以及它们的值 + -s 以可以重新用作输入的格式列出可以启动宏的键以及它们的 + 值。 + -V 列出变量名成和它们的值 + -v 以可以重新用作输入的格式列出变量的名称和它们的值 + -q 函数名 查询指定的函数可以由哪些键启动。 + -u 函数名 反绑定所有绑定至指定函数的键。 + -r 键序列 取消指定键序列的绑定。 + -f 文件名 从指定文件中读取键绑定。 + -x 键序列:shell命令\t当指定的键序列被输入时,执行指定的 shell 命令。 + -X 以可被重用的形式列出用 -x 绑定的键序列和命令。 + + 退出状态: + 除非使用了无法辨认的选项或者错误发生,否则返回0. + + [test] 估值算术表达式。 + + 将每个 ARG 参赛作为算术表达式来估值。估值的计算以定宽的整 + 数完成,不带溢出检测,不过除 0 是被置陷阱的并且会报一个错 + 误。下列操作符被按照相同的算术优先级组合。列表的顺序按照 + 优先级从高至低。 + + + \tid++, id--\t变量后置加,后置减 + \t++id, --id\t变量前置加,前置减 + \t-, +\t\t一元减法,一元加法 + \t!, ~\t\t逻辑和位取反 + \t**\t\t指数 + \t*, /, %\t\t乘法,除法,取余数 + \t+, -\t\t增加,减少 + \t<<, >>\t\t向左和向右按位移位 + \t<=, >=, <, >\t比较 + \t==, !=\t\t等于,不等于 + \t&\t\t按位与 + \t^\t\t按位异或 + \t|\t\t按位或 + \t&&\t\t逻辑与 + \t||\t\t逻辑或 + \texpr ? expr : expr + \t\t\t条件操作符 + \t=, *=, /=, %=, + \t+=, -=, <<=, >>=, + \t&=, ^=, |=\t赋值 + + Shell 变量允许作为操作数。表达式中的变量的名称会被取代以值 + (强制转换为定宽的整数)。表达式中的变量不需要打开整数属性。 + + 操作符按照优先级进行估值。括号中的子表达式将被先估值,并可取代上述表达式 + 规则。 + + 退出状态: + 如果最后一个 ARG 参数估值为 0,则 let 返回 1; 否则 let 返回 0。 + +*[other] 显示其他命令帮助信息 . +} + +helpname = { +$cmdName -> +[set] set - 设定或取消设定 shell 选项和位置参数的 +[read] read - 从标准输入读取一行并将其分为不同的域。 +[type] type - 显示命令类型的信息。 +[trap] trap - 对信号和其他事件设陷阱。 +[alias] alias - 定义或显示别名。 +[unalias] unalias - 从别名定义列表中删除每一个“名字”。 +[break] break - 退出 for、while 或 until 循环 +[continue] continue - 继续 for、while 或 until 循环。 +[builtin] builtin - 执行 shell 内建。 +[caller] caller - 返回当前子调用的上下文。 +[cd] cd - 改变 shell 工作目录。 +[pwd] pwd - 打印当前工作目录的名字。 +[true] true - 空的命令。 +[shopt] shopt - 设定和取消设定 shell 选项。 +[false] false - 返回一个不成功的结果。 +[command] command - 执行一个简单命令或者显示命令的相关信息。 +[echo] echo - 将参数写到标准输出。 +[enable] enable - 启用和禁用 shell 内建。 +[getopts] getopts - 解析选项参数。 +[exec] exec - 使用指定命令替换 shell。 +[exit] exit - 退出shell。 +[logout] logout - 退出一个登录 shell. +[fc] fc - 从历史列表中显示或者执行命令。 +[fg] fg - 将任务移至前台。 +[bg] bg - 移动任务至后台。 +[hash] hash - 记住或显示程序位置。 +[help] help - 显示内建命令的相关信息。 +[history] history - 显示或操纵历史列表。 +[jobs] jobs - 显示任务状态。 +[disown] discow - 从当前 shell 中删除任务。 +[kill] kill - 向一个任务发送一个信号。 +[let] let - 估值算术表达式。 +[shift] shift - 移位位置参数。 +[suspend] suspend - 挂起 shell 执行。 +[eval] eval - 对条件表达式进行估值。 +[times] times - 显示进程时间 +[limit] limit - 修改 shell 资源限制。 +[umask] umask - 显示或设定文件模式掩码。 +[return] return - 等待任务完成并返回退出状态。 +[wait] wait - 等待进程完成并且返回退出状态。 +[for] for - 为列表中的每个成员执行命令。 +[select] select - 从列表中选取词并且执行命令。 +[time] time - 报告管道执行的消耗时间。 +[case] case - 基于模式匹配来执行命令。 +[if] if - 根据条件执行命令。 +[while] while - 只要测试成功即执行命令。 +[until] until -当测试不同过时执行命令 +[coproc] corproc - 创建一个以 NAME 为名的副进程。 +[variables] variables - 常用 shell 变量名称和使用。 +[pushd] pushd - 将目录添加到栈中。 +[popd] popd - 从栈中删除目录。 +[dirs] dirs - 显示目录栈。 +[printf] printf -在 FORMAT 的控制下格式化并打印 ARGUMENTS 参数。 +[complete] complete - 指定 Readline 如何补全参数。 +[compgen] compgen - 依据选项显示可能的补全。 +[compopt] compopt - 修改或显示补全选项。 +[mapfile] mapfile - 从标准输入读取行到下标数组变量中。 +[unset] unset - 取消设定 shell 变量和函数的值和属性。 +[readarray] readarry - 从一个文件中读取行到数组变量中。 +[local] local -记住或显示程序位置。 +[export] export -为 shell 变量设定导出属性。 +[readonly] readonly - 标记 shell 变量为不可改变。 +[function] function - 定义 shell 函数。 +[typeset] typeset - 设置变量的值和属性。 +[source] source - 在当前 shell 中执行一个文件中的命令。 +[bind] bind - 设定 Readline 键绑定和变量。 +[test] test - 估值算术表达式。 +*[other] 显示其他命令帮助信息 . +} diff --git a/record.txt b/record.txt index 0440cf0ac33a35f15abd635c039249d23ebe965e..15e1cbf6e0cacd9bd28a930202398fdef299d533 100644 --- a/record.txt +++ b/record.txt @@ -40,3 +40,4 @@ 62 63 64 +65