参考文档 More Control and Package Management using Package Users (v1.4)
工具包: more_control_helpers
Shell 编程 特殊变量 $开头的一些特殊变量:
1Special Parameters 2 The shell treats several parameters specially. These parameters may only 3 be referenced; assignment to them is not allowed. 4 * Expands to the positional parameters, starting from one. When the 5 expansion is not within double quotes, each positional parameter expands to 6 a separate word. In contexts where it is performed, those words are 7 subject to further word splitting and pathname expansion. When the 8 expansion occurs within double quotes, it expands to a single word with the 9 value of each parameter separated by the first character of the IFS 10 special variable. That is, "$*" is equivalent to "$1c$2c...", where c 11 is the first character of the value of the IFS variable. If IFS is unset, 12 the parameters are separated by spaces. If IFS is null, the parameters are 13 joined without in‐ tervening separators. 14 @ Expands to the positional parameters, starting from one. In 15 contexts where word splitting is performed, this expands each positional 16 parameter to a separate word; if not within double quotes, these words are 17 subject to word splitting. In contexts where word splitting is not 18 performed, this expands to a single word with each po‐ sitional parameter 19 separated by a space. When the expansion occurs within double quotes, 20 each parameter ex‐ pands to a separate word. That is, "$@" is 21 equivalent to "$1" "$2" ... If the double-quoted expansion occurs within a 22 word, the expansion of the first parameter is joined with the beginning 23 part of the original word, and the expansion of the last parameter is 24 joined with the last part of the original word. When there are no posi‐ 25 tional parameters, "$@" and $@ expand to nothing (i.e., they are removed). 26 # Expands to the number of positional parameters in decimal. 27 ? Expands to the exit status of the most recently executed foreground 28 pipeline. 29 - Expands to the current option flags as specified upon invocation, by 30 the set builtin command, or those set by the shell itself (such as the -i 31 option). 32 $ Expands to the process ID of the shell. In a () subshell, it 33 expands to the process ID of the current shell, not the subshell. 34 ! Expands to the process ID of the job most recently placed into the 35 background, whether executed as an asynchronous command or using the bg 36 builtin (see JOB CONTROL below). 37 0 Expands to the name of the shell or shell script. This is set 38 at shell initialization. If bash is invoked with a file of commands, $0 is 39 set to the name of that file. If bash is started with the -c option, then 40 $0 is set to the first argument after the string to be executed, if 41 one is present. Otherwise, it is set to the filename used to invoke bash, 42 as given by argument zero. type命令 默认的man好像显示的不是bash command的type, 因而去别处找了一份mannual:
...