📄 faq
字号:
unset BASH_ENVA8) I just changed my login shell to bash, and now I can't FTP into my machine. Why not?You must add the full pathname to bash to the file /etc/shells. Asnoted in the answer to the previous question, many systems requirethis before you can make bash your login shell. Most versions of ftpd use this file to prohibit `special' userssuch as `uucp' and `news' from using FTP. A9) What's the `POSIX Shell and Utilities standard'?POSIX is a name originally coined by Richard Stallman for afamily of open system standards based on UNIX. There are anumber of aspects of UNIX under consideration forstandardization, from the basic system services at the systemcall and C library level to applications and tools to systemadministration and management. Each area of standardization isassigned to a working group in the 1003 series. The POSIX Shell and Utilities standard was originally developed byIEEE Working Group 1003.2 (POSIX.2). Today it has been merged withthe original 1003.1 Working Group and is maintained by the AustinGroup (a joint working group of the IEEE, The Open Group andISO/IEC SC22/WG15). Today the Shell and Utilities are a volumewithin the set of documents that make up IEEE Std 1003.1-2001, andthus now the former POSIX.2 (from 1992) is now part of the currentPOSIX.1 standard (POSIX 1003.1-2001). The Shell and Utilities volume concentrates on the commandinterpreter interface and utility programs commonly executed fromthe command line or by other programs. The standard is freelyavailable on the web at http://www.UNIX-systems.org/version3/ . Work continues at the Austin Group on maintenance issues; seehttp://www.opengroup.org/austin/ to join the discussions. Bash is concerned with the aspects of the shell's behavior definedby the POSIX Shell and Utilities volume. The shell commandlanguage has of course been standardized, including the basic flowcontrol and program execution constructs, I/O redirection andpipelining, argument handling, variable expansion, and quoting. The `special' builtins, which must be implemented as part of theshell to provide the desired functionality, are specified asbeing part of the shell; examples of these are `eval' and`export'. Other utilities appear in the sections of POSIX notdevoted to the shell which are commonly (and in some cases mustbe) implemented as builtin commands, such as `read' and `test'. POSIX also specifies aspects of the shell's interactivebehavior as part of the UPE, including job control and commandline editing. Only vi-style line editing commands have beenstandardized; emacs editing commands were left out due toobjections.The latest version of the POSIX Shell and Utilities standard isavailable (now updated to the 2004 Edition) as part of the SingleUNIX Specification Version 3 athttp://www.UNIX-systems.org/version3/A10) What is the bash `posix mode'?Although bash is an implementation of the POSIX shellspecification, there are areas where the bash default behaviordiffers from that spec. The bash `posix mode' changes the bashbehavior in these areas so that it obeys the spec more closely. Posix mode is entered by starting bash with the --posix or'-o posix' option or executing `set -o posix' after bash is running.The specific aspects of bash which change when posix mode isactive are listed in the file POSIX in the bash distribution.They are also listed in a section in the Bash Reference Manual(from which that file is generated).Section B: The latest versionB1) What's new in version 4.2?Bash-4.2 is the second revision to the fourth major release of bash.Bash-4.2 contains the following new features (see the manual page forcomplete descriptions and the CHANGES and NEWS files in the bash-4.2distribution):o `exec -a foo' now sets $0 to `foo' in an executable shell script without a leading #!.o Subshells begun to execute command substitutions or run shell functions or builtins in subshells do not reset trap strings until a new trap is specified. This allows $(trap) to display the caller's traps and the trap strings to persist until a new trap is set.o `trap -p' will now show signals ignored at shell startup, though their disposition still cannot be modified.o $'...', echo, and printf understand \uXXXX and \UXXXXXXXX escape sequences.o declare/typeset has a new `-g' option, which creates variables in the global scope even when run in a shell function.o test/[/[[ have a new -v variable unary operator, which returns success if `variable' has been set.o Posix parsing changes to allow `! time command' and multiple consecutive instances of `!' (which toggle) and `time' (which have no cumulative effect).o Posix change to allow `time' as a command by itself to print the elapsed user, system, and real times for the shell and its children.o $((...)) is always parsed as an arithmetic expansion first, instead of as a potential nested command substitution, as Posix requires.o A new FUNCNEST variable to allow the user to control the maximum shell function nesting (recursive execution) level.o The mapfile builtin now supplies a third argument to the callback command: the line about to be assigned to the supplied array index.o The printf builtin has as new %(fmt)T specifier, which allows time values to use strftime-like formatting.o There is a new `compat41' shell option.o The cd builtin has a new Posix-mandated `-e' option.o Negative subscripts to indexed arrays, previously errors, now are treated as offsets from the maximum assigned index + 1.o Negative length specifications in the ${var:offset:length} expansion, previously errors, are now treated as offsets from the end of the variable.o Parsing change to allow `time -p --'.o Posix-mode parsing change to not recognize `time' as a keyword if the following token begins with a `-'. This means no more Posix-mode `time -p'. Posix interpretation 267.o There is a new `lastpipe' shell option that runs the last command of a pipeline in the current shell context. The lastpipe option has no effect if job control is enabled.o History expansion no longer expands the `$!' variable expansion.o Posix mode shells no longer exit if a variable assignment error occurs with an assignment preceding a command that is not a special builtin.o Non-interactive mode shells exit if -u is enabled an an attempt is made to use an unset variable with the % or # expansions, the `//', `^', or `,' expansions, or the parameter length expansion.o Posix-mode shells use the argument passed to `.' as-is if a $PATH search fails, effectively searching the current directory. Posix-2008 change.A short feature history dating back to Bash-2.0:Bash-4.1 contained the following new features:o Here-documents within $(...) command substitutions may once more be delimited by the closing right paren, instead of requiring a newline.o Bash's file status checks (executable, readable, etc.) now take file system ACLs into account on file systems that support them.o Bash now passes environment variables with names that are not valid shell variable names through into the environment passed to child processes.o The `execute-unix-command' readline function now attempts to clear and reuse the current line rather than move to a new one after the command executes.o `printf -v' can now assign values to array indices.o New `complete -E' and `compopt -E' options that work on the "empty" completion: completion attempted on an empty command line.o New complete/compgen/compopt -D option to define a `default' completion: a completion to be invoked on command for which no completion has been defined. If this function returns 124, programmable completion is attempted again, allowing a user to dynamically build a set of completions as completion is attempted by having the default completion function install individual completion functions each time it is invoked.o When displaying associative arrays, subscripts are now quoted.o Changes to dabbrev-expand to make it more `emacs-like': no space appended after matches, completions are not sorted, and most recent history entries are presented first.o The [[ and (( commands are now subject to the setting of `set -e' and the ERR trap.o The source/. builtin now removes NUL bytes from the file before attempting to parse commands.o There is a new configuration option (in config-top.h) that forces bash to forward all history entries to syslog.o A new variable $BASHOPTS to export shell options settable using `shopt' to child processes.o There is a new confgure option that forces the extglob option to be enabled by default.o New variable $BASH_XTRACEFD; when set to an integer bash will write xtrace output to that file descriptor.o If the optional left-hand-side of a redirection is of the form {var}, the shell assigns the file descriptor used to $var or uses $var as the file descriptor to move or close, depending on the redirection operator.o The < and > operators to the [[ conditional command now do string comparison according to the current locale.o Programmable completion now uses the completion for `b' instead of `a' when completion is attempted on a line like: a $(b c.o Force extglob on temporarily when parsing the pattern argument to the == and != operators to the [[ command, for compatibility.o Changed the behavior of interrupting the wait builtin when a SIGCHLD is received and a trap on SIGCHLD is set to be Posix-mode only.o The read builtin has a new `-N nchars' option, which reads exactly NCHARS characters, ignoring delimiters like newline.o The mapfile/readarray builtin no longer stores the commands it invokes via callbacks in the history list.o There is a new `compat40' shopt option.o The < and > operators to [[ do string comparisons using the current locale only if the compatibility level is greater than 40 (set to 41 by default).o New bindable readline function: menu-complete-backward.o In the readline vi-mode insertion keymap, C-n is now bound to menu-complete by default, and C-p to menu-complete-backward.o When in readline vi command mode, repeatedly hitting ESC now does nothing, even when ESC introduces a bound key sequence. This is closer to how historical vi behaves.o New bindable readline function: skip-csi-sequence. Can be used as a default to consume key sequences generated by keys like Home and End without having to bind all keys.o New bindable readline variable: skip-completed-text, active when completing in the middle of a word. If enabled, it means that characters in the completion that match characters in the remainder of the word are "skipped" rather than inserted into the line.o The pre-readline-6.0 version of menu completion is available as "old-menu-complete" for users who do not like the readline-6.0 version.o New bindable readline variable: echo-control-characters. If enabled, and the tty ECHOCTL bit is set, controls the echoing of characters corresponding to keyboard-generated signals.o New bindable readline variable: enable-meta-key. Controls whether or not readline sends the smm/rmm sequences if the terminal indicates it has a meta key that enables eight-bit characters.Bash-4.0 contained the following new features:o When using substring expansion on the positional parameters, a starting index of 0 now causes $0 to be prefixed to the list.o There is a new variable, $BASHPID, which always returns the process id of the current shell.o There is a new `autocd' option that, when enabled, causes bash to attempt to `cd' to a directory name that is supplied as the first word of a simple command.o There is a new `checkjobs' option that causes the shell to check for and report any running or stopped jobs at exit.o The programmable completion code exports a new COMP_TYPE variable, set to a character describing the type of completion being attempted.o The programmable completion code exports a new COMP_KEY variable, set to the character that caused the completion to be invoked (e.g., TAB).o The programmable completion code now uses the same set of characters as readline when breaking the command line into a list of words.o The block multiplier for the ulimit -c and -f options is now 512 when in Posix mode, as Posix specifies.o Changed the behavior of the read builtin to save any partial input received in the specified variable when the read builtin times out. This also results in variables specified as arguments to read to be set to the empty string when there is no input available. When the read builtin times out, it returns an exit status greater than 128.o The shell now has the notion of a `compatibility level', controlled by new variables settable by `shopt'. Setting this variable currently restores the bash-3.1 behavior when processing quoted strings on the rhs of the `=~' operator to the `[[' command.o The `ulimit' builtin now has new -b (socket buffer size) and -T (number of threads) options.o There is a new `compopt' builtin that allows completion functions to modify
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -