GNU Bash 参考手册(中文版)(六)

10 安装 Bash

本章提供在受支持的平台上安装 Bash 的基本说明。该发行版支持 GNU 操作系统、几乎所有版本的 Unix,以及 BeOS 和 Interix 等若干非 Unix 系统。Windows 平台另有其他独立的移植版本。

10.1 基本安装

以下是为 Bash 编译安装的说明。

编译 Bash 最简单的办法是:

  1. cd 到包含源代码的目录,输入 ./configure 为你的系统配置 Bash。如果你在旧版 System V 上使用 csh,可能需要输入 sh ./configure 来代替,以免 csh 试图自己执行 configure

    运行 configure 需要一些时间。运行期间它会打印消息,说明正在检查哪些特性。

  2. 输入 make 编译 Bash 并构建 bashbug 缺陷报告脚本。

  3. (可选)输入 make tests 运行 Bash 测试套件。

  4. 输入 make install 安装 bashbashbug。这还会安装手册页和 Info 文件、消息翻译文件、一些补充文档、一批可加载内建命令示例,以及一套用于开发可加载内建命令的头文件。你可能需要额外权限才能把 bash 安装到目标位置,这可能要用 sudo make install。关于控制 bash 及其他文件安装位置的信息见下文(参见第 10.4 节(安装名称))。

configure 这个 Shell 脚本会尝试为编译期间使用的各种系统相关变量猜测正确的值。它用这些值在包的每个目录中创建 Makefile(顶层目录、builtinsdocposupport 目录、lib 下的每个目录,以及其他若干目录)。它还创建包含系统相关定义的 config.h 文件。最后,它创建一个名为 config.status 的 Shell 脚本,将来可以运行它来重新创建当前配置;一个名为 config.cache 的文件,保存其测试结果以加快重新配置;以及一个包含编译器输出的 config.log 文件(主要用于调试 configure)。如果某个时候 config.cache 中包含你不想保留的结果,可以删除或编辑它。

想进一步了解 configure 脚本认识的选项和参数,在 Bash 源目录中的 Bash 提示符下输入:

bash-4.2$ ./configure --help

如果想在与源代码目录不同的目录中构建 Bash——例如要为多种架构构建——只需使用 configure 脚本的完整路径。下面的命令将根据 /usr/local/src/bash-4.4 中的源代码,在 /usr/local/build 下的目录中构建 Bash:

mkdir /usr/local/build/bash-4.4
cd /usr/local/build/bash-4.4
bash /usr/local/src/bash-4.4/configure
make

有关在与源代码不同的目录中构建的更多信息,参见第 10.3 节(为多种架构编译)。

如果编译 Bash 需要做一些不寻常的事情,请尽量想办法让 configure 能检查是否需要做这些事,并把补丁(diff)或说明寄给 bash-maintainers@gnu.org,以便在下一次发行时加以考虑。

configure.ac 文件由一个名为 Autoconf 的程序用来创建 configure。只有当你想修改 configure.ac,或用更新版本的 Autoconf 重新生成 configure 时才需要它。如果这样做,请确保使用的是 Autoconf 2.69 或更新版本。

输入 make clean 可以删除源代码目录中的程序二进制文件和目标文件。若还要删除 configure 创建的文件(以便为另一种类型的计算机编译 Bash),输入 make distclean

译者注make cleanmake distclean 的区别:前者只清除编译产物(目标文件、可执行文件),保留 configure 生成的 Makefileconfig.h 等,之后可直接重新 make;后者在此基础上连 configure 生成的文件一并删除,相当于回到刚解包的状态,之后要为其他平台或换用不同选项重新 configure 时才需要。

10.2 编译器与选项

有些系统要求 configure 脚本不知道的不寻常的编译或链接选项。你可以在环境中设置变量,为 configure 提供初始值。使用 Bourne 兼容的 Shell,可以在命令行上这样做:

CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure

在装有 env 程序的系统上,可以这样做:

env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure

配置过程在可用时会用 GCC 构建 Bash。

10.3 为多种架构编译

可以把每种架构的目标文件放在各自的目录中,从而同时为多种计算机编译 Bash。为此,必须使用支持 VPATH 变量的 make 版本,如 GNU makecd 到希望放置目标文件和可执行文件的目录,并从源目录运行 configure 脚本(参见第 10.1 节(基本安装))。可能需要提供 --srcdir=PATH 参数,告诉 configure 源文件在哪里。configure 会自动在 configure 所在的目录和 .. 中查找源代码。

译者注:这是 GNU 包常见的“异地构建”(out-of-tree build)方式:源目录保持只读不变,各架构在各自的构建目录中生成自己的目标文件和 MakefileVPATH 是 GNU make 的机制,configure 在构建目录中运行时会通过它找到源目录中的文件;若构建目录的位置特殊,configure 找不到源目录,就用 --srcdir=PATH 显式指定。

如果必须使用不支持 VPATH 变量的 make,可以一次一种架构地在源代码目录中编译 Bash。为一种架构安装 Bash 之后,在为另一种架构重新配置之前,先运行 make distclean

另外,如果你的系统支持符号链接,可以用 support/mkclone 脚本创建一个构建树,其中的文件都是指向源目录中每个文件的符号链接。下面是一个例子,它从源目录 /usr/gnu/src/bash-2.0 在当前目录中创建一个构建目录:

bash /usr/gnu/src/bash-2.0/support/mkclone -s /usr/gnu/src/bash-2.0 .

mkclone 脚本需要 Bash,因此必须先为至少一种架构构建 Bash,才能为其他架构创建构建目录。

10.4 安装名称

默认情况下,make install 会安装到 /usr/local/bin/usr/local/man 等目录;也就是说,“安装前缀”(installation prefix)默认为 /usr/local。可以通过给 configure 提供 --prefix=PATH 选项,或运行 make install 时为 prefix 这个 make 变量指定值(如 make install prefix=PATH),来指定不同于 /usr/local 的安装前缀。prefix 变量为 exec_prefix 以及安装 Bash 时使用的其他变量提供默认值。

可以为架构相关文件和架构无关文件指定不同的安装前缀。如果给 configure 提供 --exec-prefix=PATH 选项,make install 将把 PATH 用作安装程序和库的前缀。文档和其他数据文件仍使用常规前缀。

如果只想在单次运行中更改安装位置,可以把这些变量作为参数指定给 makemake install exec_prefix=/ 会把 bashbashbug 安装到 /bin,而不是默认的 /usr/local/bin

如果不想改动系统,而想看看 Bash 会安装哪些文件、装到哪里,可以把 DESTDIR 变量作为参数指定给 make。它的值应该是你希望用作示例安装树根目录的绝对目录路径。例如:

mkdir /fs1/bash-install
make install DESTDIR=/fs1/bash-install

会把 bash 安装到 /fs1/bash-install/usr/local/bin/bash,把文档安装到 /fs1/bash-install/usr/local/share 下的目录中,把示例可加载内建命令安装到 /fs1/bash-install/usr/local/lib/bash,等等。你可以用通常的 exec_prefixprefix 变量,改变 DESTDIR 值之下的目录路径。

译者注DESTDIR 是打包工具常用的“暂存安装”(staged install)手段:不真正安装到系统目录,而是装到以 DESTDIR 为根的目录树中,之后整体打包或转移。注意 --prefix 等配置期选项决定的是目录树内部的结构(如 usr/local/bin),DESTDIR 只负责在最外层加一个前缀。

GNU Makefile 标准对这些变量及其作用有更完整的描述。

10.5 指定系统类型

有些特性 configure 无法自动推断,但需要根据 Bash 将要运行的主机类型来确定。通常 configure 能推断出来,但如果它打印消息说无法猜测主机类型,就给它 --host=TYPE 选项。TYPE 既可以是系统类型的短名称,如 sun4,也可以是包含三个字段的规范名称:CPU-COMPANY-SYSTEM(例如 i386-unknown-freebsd4.2)。

每个字段的可能取值参见 support/config.sub 文件。

10.6 共享默认配置

如果想为 configure 脚本设置共享的默认值,可以创建一个名为 config.site 的站点 Shell 脚本,为 CCcache_fileprefix 之类的变量提供默认值。configure 会先查找 PREFIX/share/config.site(如果存在),再查找 PREFIX/etc/config.site(如果存在)。也可以把 CONFIG_SITE 环境变量设置为站点脚本的位置。警告:Bash 的 configure 会查找站点脚本,但不是所有 configure 脚本都会。

译者注config.site 适合在站点范围内统一默认设置(如统一的 CCCFLAGS、安装前缀),多个包的 configure 可以共享。例如把 prefix=/opt/gnu 写进站点脚本,就不用每次敲 --prefixCONFIG_SITE 可直接指向某个脚本文件,优先级高于自动查找。

10.7 操作控制

configure 识别下列选项来控制它的运行方式。

选项 含义
--cache-file=FILE 使用并把测试结果保存在 FILE 中,而不是 ./config.cache。把 FILE 设为 /dev/null 可禁用缓存,用于调试 configure
--help 打印 configure 的选项摘要并退出。
--quiet--silent-q 不打印说明正在做哪些检查的消息。
--srcdir=DIR 在目录 DIR 中查找 Bash 源代码。通常 configure 能自动确定该目录。
--version 打印生成 configure 脚本所用的 Autoconf 版本并退出。

configure 还接受一些其他不太常用的套话式(boilerplate)选项。configure --help 会打印完整列表。

10.8 可选功能

Bash 的 configure 有许多 --enable-FEATURE 选项,其中 FEATURE 表示 Bash 的一个可选部分。还有几个 --with-PACKAGE 选项,其中 PACKAGE 是 bash-mallocafs 之类的东西。要关闭某个包的默认使用,用 --without-PACKAGE。要在不带某个默认启用的功能的情况下配置 Bash,用 --disable-FEATURE

以下是 Bash 的 configure 识别的 --enable---with- 选项的完整列表。

--with-afs

如果你正在使用 Transarc 的 Andrew 文件系统(AFS),请启用此选项。

--with-bash-malloc

使用 lib/malloc 目录中的 Bash 版 malloc。它不是 GNU libc 中出现的那个 malloc,而是一个最初源自 4.2 BSD malloc 的自定义版本。这个 malloc 非常快,但每次分配都会浪费一些空间,尽管它使用了几种技术来尽量减少浪费。此选项默认启用。NOTES 文件包含一份应关闭此选项的系统列表,而且 configure 会自动为若干系统关闭它。

--with-curses

使用 curses 库而不是 termcap 库。由于大多数系统把 termcap 函数包含在 curses 库中,configure 通常会自动选择这一项。

--with-gnu-malloc

--with-bash-malloc 的同义词。

--with-installed-readline[=PREFIX]

定义此选项,使 Bash 与本地安装的 Readline 版本链接,而不是 lib/readline 中的版本。这只对 Readline 5.0 及以后版本有效。如果 PREFIX 是 yes 或未提供,当已安装的 Readline 不在系统的标准 include 和库目录中时,configure 使用 make 变量 includedirlibdir(默认是 prefix 的子目录)的值来查找已安装的 Readline。如果 PREFIX 是 no,Bash 与 lib/readline 中的版本链接。如果 PREFIX 设为任何其他值,configure 把它视为目录路径名,并在该目录的子目录中查找已安装的 Readline(头文件在 PREFIX/include,库在 PREFIX/lib)。Bash 的默认行为是与构建目录的 lib/readline 子目录中构建的静态库链接。

译者注:此选项用于让 Bash 链接系统自装的 Readline(例如发行版提供的 libreadline-dev),而不是随 Bash 源码自带的那份。常见用法是 ./configure --with-installed-readline=/usr(或发行版默认路径下的 --with-installed-readline=yes)。用自带版本的好处是行为与手册完全一致;用系统版本则能共享系统库的更新与修复。注意只支持 Readline 5.0 及以后版本。

--with-libintl-prefix[=PREFIX]

定义此选项,使 Bash 与本地安装的 libintl 库版本链接,而不是 lib/intl 中的版本。

--with-libiconv-prefix[=PREFIX]

定义此选项,使 Bash 在 PREFIX 中而不是标准系统位置查找 libiconv。Bash 发行版不包含这个库。

--enable-minimal-config

生成一个功能极简的 Shell,更接近历史上的 Bourne shell。

还有若干 --enable- 选项改变 Bash 的编译、链接和安装方式,而不是改变运行时功能。

--enable-largefile

如果操作系统需要特殊的编译器选项才能构建可访问大文件的程序,则启用对大文件的支持( http://www.unix.org/version2/whatsnew/lfs20mar.html )。如果操作系统提供大文件支持,此选项默认启用。

--enable-profiling

构建一个每次执行时都产生剖析(profiling)信息、供 gprof 处理的 Bash 二进制文件。

--enable-separate-helpfiles

help 内建命令显示的文档使用外部文件,而不是把文本存储在内部。

--enable-static-link

如果使用 gcc,这会使 Bash 静态链接。可用来构建一个作为 root 的 Shell 的版本。

minimal-config 选项可用于禁用下面所有选项;但由于它先被处理,之后仍可以用 --enable-FEATURE 单独启用个别选项。

下列所有选项都默认启用,除非操作系统不提供必要的支持;例外是 alt-array-implementationdisabled-builtinsdirexpand-defaultstrict-posix-defaultxpg-echo-default

译者注:也就是说,默认构建出的 Bash 已包含别名、花括号展开、命令历史、作业控制、Readline 等全部常用功能;只有在确实需要裁剪(如嵌入式环境或追求最小体积,可用 --enable-minimal-config)时才需要 --disable-FEATURE。上面列出的五个例外默认是关闭的:它们分别对应 --enable-alt-array-implementation--enable-disabled-builtins--enable-direxpand-default--enable-strict-posix-default--enable-xpg-echo-default

--enable-alias

允许别名展开,并包含 aliasunalias 内建命令(参见第 6.6 节(别名))。

--enable-alt-array-implementation

使用数组的另一种实现来构建 Bash(参见第 6.7 节(数组))。这种实现访问速度更快,但代价是占用更多内存(有时多好几倍,取决于数组的稀疏程度)。

--enable-arith-for-command

包含对行为类似 C 语言 for 语句的 for 命令另一种形式的支持(参见第 3.2.5.1 节(循环结构))。

--enable-array-variables

包含一维数组 Shell 变量的支持(参见第 6.7 节(数组))。

--enable-bang-history

包含类 csh 的历史替换支持(参见第 9 章(交互式使用历史记录))。

--enable-bash-source-fullpath-default

把上文第 4.3.2 节(shopt 内建命令)中描述的 bash_source_fullpath Shell 选项的默认值设为启用。这控制文件名如何赋给 BASH_SOURCE 数组变量。

--enable-brace-expansion

包含类 csh 的花括号展开(b{a,b}cbac bbc)。完整描述参见第 3.5.1 节(花括号展开)。

--enable-casemod-attributes

declare 内建命令和赋值语句中包含大小写修改属性的支持。例如,带有 uppercase 属性的变量在赋值时,其值会被转换为大写。

--enable-casemod-expansion

包含大小写修改单词展开的支持。

--enable-command-timing

包含把 time 识别为保留字、并显示 time 后面的管道计时统计信息的支持(参见第 3.2.3 节(管道))。这使管道、Shell 复合命令、Shell 内建命令和 Shell 函数都可以计时,而外部命令不容易做到这一点。

--enable-cond-command

包含 [[ 条件命令的支持(参见第 3.2.5.2 节(条件结构))。

--enable-cond-regexp

包含在 [[ 条件命令中用 =~ 二元操作符匹配 POSIX 正则表达式的支持(参见第 3.2.5.2 节(条件结构))。

--enable-coprocesses

包含协程和 coproc 保留字的支持(参见第 3.2.6 节(协程))。

--enable-debugger

包含 Bash 调试器(单独发行)的支持。

--enable-dev-fd-stat-broken

如果对 /dev/fd/N 调用 stat 返回的结果,与对文件描述符 N 调用 fstat 返回的结果不同,请提供此选项以启用一种变通方法。这对测试文件属性的条件命令有影响。

--enable-direxpand-default

使 direxpand Shell 选项(参见第 4.3.2 节(shopt 内建命令))在 Shell 启动时默认启用。它通常默认禁用。

--enable-directory-stack

包含类 csh 的目录栈以及 pushdpopddirs 内建命令的支持(参见第 6.8 节(目录栈))。

--enable-disabled-builtins

即使 xxx 已用 enable -n xxx 禁用,也允许通过 builtin xxx 调用内建命令。builtinenable 内建命令的细节参见第 4.2 节(Bash 内建命令)。

--enable-dparen-arithmetic

包含 ((...)) 命令的支持(参见第 3.2.5.2 节(条件结构))。

--enable-extended-glob

包含上文第 3.5.8.1 节(模式匹配)中描述的扩展模式匹配特性的支持。

--enable-extended-glob-default

把上文第 4.3.2 节(shopt 内建命令)中描述的 extglob Shell 选项的默认值设为启用。

--enable-function-import

包含从环境中导入由另一个 Shell 实例导出的函数定义的支持。此选项默认启用。

--enable-glob-asciiranges-default

把上文第 4.3.2 节(shopt 内建命令)中描述的 globasciiranges Shell 选项的默认值设为启用。这控制模式匹配括号表达式中字符范围的行为。

--enable-help-builtin

包含 help 内建命令,它显示 Shell 内建命令和变量的帮助信息(参见第 4.2 节(Bash 内建命令))。

--enable-history

包含命令历史以及 fchistory 内建命令(参见第 9.1 节(Bash 的历史记录设施))。

--enable-job-control

如果操作系统支持,启用作业控制功能(参见第 7 章(作业控制))。

--enable-multibyte

如果操作系统提供必要的支持,启用多字节字符支持。

--enable-net-redirections

启用重定向中对 /dev/tcp/HOST/PORT/dev/udp/HOST/PORT 形式文件名的特殊处理(参见第 3.6 节(重定向))。

--enable-process-substitution

如果操作系统提供必要的支持,启用进程替换(参见第 3.5.6 节(进程替换))。

--enable-progcomp

启用可编程补全功能(参见第 8.6 节(可编程补全))。如果没有启用 Readline,此选项无效。

--enable-prompt-string-decoding

打开对 $PS0$PS1$PS2$PS4 提示符字符串中许多反斜杠转义字符的解释。提示符字符串转义序列的完整列表参见第 6.9 节(控制提示符)。

--enable-readline

包含用 Bash 版 Readline 库进行命令行编辑和历史记录的支持(参见第 8 章(命令行编辑))。

--enable-restricted

包含“受限 Shell”的支持。如果启用,Bash 在作为 rbash 被调用时进入受限模式。受限模式的描述参见第 6.10 节(受限 Shell)。

--enable-select

包含 select 复合命令,它可生成简单的菜单(参见第 3.2.5.2 节(条件结构))。

--enable-single-help-strings

help 内建命令显示的文本按每个帮助主题存储为单个字符串。这有助于把文本翻译成不同语言。如果编译器不能处理非常长的字符串字面量,可能需要禁用此选项。

--enable-strict-posix-default

使 Bash 默认符合 POSIX(参见第 6.11.2 节(Bash 的 POSIX 模式))。

--enable-translatable-strings

启用 $"STRING" 可翻译字符串的支持(参见第 3.1.2.5 节(区域设置相关的翻译($"...")))。

--enable-usg-echo-default

--enable-xpg-echo-default 的同义词。

--enable-xpg-echo-default

使 echo 内建命令默认展开反斜杠转义字符,而不需要 -e 选项。这把 xpg_echo Shell 选项的默认值设为 on,使 Bash 的 echo 行为更接近 Single Unix Specification 第 3 版中规定的版本。echo 识别的转义序列参见第 4.2 节(Bash 内建命令)。

config-top.h 文件包含 configure 无法设置的选项的 C 预处理器 #define 语句。其中有些并不打算改动;如果改动,要当心后果。阅读每个定义附带的注释,可了解其作用的更多信息。

附录 A 报告缺陷

请报告您在 Bash 中发现的所有缺陷。但首先,您应当确认这确实是一个缺陷,并且它在最新版本的 Bash 中仍然存在。最新发布的 Bash 版本始终可以通过 FTP 从 ftp://ftp.gnu.org/pub/gnu/bash/ 获取,也可以从 http://git.savannah.gnu.org/cgit/bash.git/snapshot/bash-master.tar.gz 获取。

一旦您确认缺陷确实存在,请使用 bashbug 命令提交缺陷报告,或使用 Bash 项目页面( https://savannah.gnu.org/projects/bash/ )上的表单。如果您有修复方案,也欢迎一并提交!建议和「哲学性」的缺陷报告可以邮寄到 bug-bash@gnu.orghelp-bash@gnu.org

所有缺陷报告都应包含:

  • Bash 的版本号。
  • 硬件和操作系统。
  • 编译 Bash 所用的编译器。
  • 对缺陷行为的描述。
  • 一个能触发该缺陷并可用于复现它的简短脚本或「配方」(recipe)。

bashbug 会自动将前三项填入其提供的缺陷报告模板中。

请将与本手册有关的报告发送到 bug-bash@gnu.org

译者注bashbug 会调用 $EDITOR 环境变量指定的编辑器(如 vim)打开一份报告模板,其中 Bash 版本号、操作系统和编译器信息已自动填好,您只需补充缺陷行为描述和可复现的示例脚本,保存并退出编辑器后报告即被发送到 GNU Bash 维护者处。

附录 B 与 Bourne Shell 的主要差异

Bash 与 Bourne Shell 实现了基本相同的语法、参数与变量展开、重定向和引号机制。Bash 以 POSIX 标准作为这些功能应如何实现、应如何行为的规范。传统 Bourne shell 与 Bash 之间仍存在一些差异;本节简要列出其中重要的差异。其中不少差异在前面各节中已有更深入的说明。本节以 SVR4.2 所附的 sh(历史上最后一个版本的 Bourne shell)作为比较基准。

译者注:本节中的 sh 指 SVR4.2 自带的、历史上最后一代 Bourne shell,而不是许多 Linux 发行版中把 Bash 软链接到 /bin/sh 的那个 sh。Bash 的 POSIX 模式(参见第 6.11.2 节(Bash 的 POSIX 模式))是让 Bash 尽量贴近 POSIX 规范行为的开关,它与 SVR4.2 的历史行为并不完全一致。

  • Bash 遵循 POSIX 标准,即使 POSIX 规范与传统 sh 的行为不同也是如此(参见第 6.11.2 节(Bash 的 POSIX 模式))。

  • Bash 支持多字符的调用选项(参见第 6.1 节(调用 Bash))。

  • Bash 的受限模式更为实用(参见第 6.10 节(受限 Shell));SVR4.2 shell 的受限模式过于局限。

  • Bash 具有命令行编辑功能(参见第 8 章(命令行编辑))和 bind 内建命令。

  • Bash 提供可编程的单词补全机制(参见第 8.6 节(可编程补全)),并提供 completecompgencompopt 内建命令来操作它。

  • Bash 会解释提示符字符串变量(PS0PS1PS2PS4)中的多种反斜杠转义序列(参见第 6.9 节(控制提示符))。

  • Bash 会展开并显示 PS0 提示符字符串变量。

  • 在输出每个主提示符之前,Bash 会运行 PROMPT_COMMAND 数组变量中的命令。

  • Bash 具备命令历史功能(参见第 9.1 节(Bash 的历史记录设施)),并提供 historyfc 内建命令来操作它。Bash 的历史列表会保存时间戳信息,并使用 HISTTIMEFORMAT 变量的值来显示。

  • Bash 实现了类似 csh 的历史展开(参见第 9.3 节(历史展开))。

  • Bash 支持 $'...' 引号语法,会展开单引号之间文本中的 ANSI-C 反斜杠转义字符(参见第 3.1.2.4 节(ANSI-C 引号))。

    译者注$'...' 中可以使用 ANSI-C 转义序列,例如 \n(换行)、\t(制表符)、\xHH(十六进制字符)等:

    # 译者注示例:$'...' 中的转义序列
    $ echo $'a\tb\nc'
    a	b
    c
    
  • Bash 支持 $"..." 引号语法,并对双引号之间的字符进行区域设置相关的翻译。调用选项 -D--dump-strings--dump-po-strings 会列出脚本中发现的全部可翻译字符串(参见第 3.1.2.5 节(区域设置相关的翻译))。

    译者注$"..." 的翻译依赖 gettext 工具链;在未启用区域翻译的系统上,它与普通双引号字符串效果相同。bash -D 会列出脚本中所有 $"..." 可翻译字符串,输出格式可直接交给 xgettext 使用:

    # 译者注示例:bash -D 列出可翻译字符串(不执行脚本)
    $ echo 'echo $"hello world"' > t.sh
    $ bash -D t.sh
    "hello world"
    
  • Bash 包含花括号展开(参见第 3.5.1 节(花括号展开))和波浪号展开(参见第 3.5.2 节(波浪号展开))。

  • Bash 实现了命令别名,以及 aliasunalias 内建命令(参见第 6.6 节(别名))。

  • Bash 实现了 ! 保留字,用于取反管道的返回值(参见第 3.2.3 节(管道))。当 if 语句需要在测试失败时才采取行动时,这一功能非常有用。set-o pipefail 选项会使管道在任一命令失败时返回失败状态(参见第 4.3.1 节(set 内建命令))。

  • Bash 具有 time 保留字和命令计时功能(参见第 3.2.3 节(管道))。计时统计信息的显示方式可以用 TIMEFORMAT 变量控制。

  • Bash 提供协程和 coproc 保留字(参见第 3.2.6 节(协程))。

  • Bash 实现了 for (( EXPR1 ; EXPR2 ; EXPR3 )) 算术 for 命令,与 C 语言类似(参见第 3.2.5.1 节(循环结构))。

  • Bash 包含 select 复合命令,可以生成简单菜单(参见第 3.2.5.2 节(条件结构))。

  • Bash 包含 [[ 复合命令,使条件测试成为 Shell 语法的一部分(参见第 3.2.5.2 节(条件结构)),并支持可选的正则表达式匹配。

  • Bash 为 case[[ 结构提供可选的忽略大小写匹配(参见第 3.2.5.2 节(条件结构))。

  • Bash 为 case 语句提供额外的动作列表终止符:;&;;&(参见第 3.2.5.2 节(条件结构))。

  • Bash 提供 Shell 算术、(( 复合命令(参见第 3.2.5.2 节(条件结构))、let 内建命令和算术展开(参见第 6.5 节(Shell 算术))。

  • Bash 具有一维数组变量(参见第 6.7 节(数组)),以及使用它们所需的变量展开和赋值语法。多个 Bash 内建命令带有作用于数组的选项。Bash 还提供若干内建的数组变量。

  • Shell 初始环境中的变量会自动导出到子进程(参见第 3.7.3 节(命令执行环境))。Bourne shell 通常不会这样做,除非用 export 命令显式标记这些变量。

  • Bash 可以用 ${NUM} 展开 $9 以上的位置参数(参见第 3.5.3 节(Shell 参数展开))。

  • Bash 支持 += 赋值操作符,它会向左侧变量的值追加内容(参见第 3.4 节(Shell 参数))。

    译者注+= 对普通字符串变量是文本追加;对带整数属性(declare -i)的变量则是算术加并赋值;对数组变量则是追加元素:

    # 译者注示例:+= 追加赋值在不同类型变量上的效果
    $ x=hello; x+=world; echo "$x"
    helloworld
    $ n=10; n+=5; echo "$n"
    105
    $ declare -i m=10; m+=5; echo "$m"
    15
    
  • Bash 包含 POSIX 模式删除展开 %#%%##,用于删除变量值开头或结尾的子串(参见第 3.5.3 节(Shell 参数展开))。

  • 支持 ${#xx} 展开,它返回 ${xx} 的长度(参见第 3.5.3 节(Shell 参数展开))。

  • 提供 ${var:OFFSET[:LENGTH]} 展开,它展开为 var 的值中从 OFFSET 开始、长度为 LENGTH 的子串(参见第 3.5.3 节(Shell 参数展开))。

  • 提供 ${VAR/PATTERN/REPLACEMENT} 展开,它在 VAR 的值中匹配 PATTERN 并将其替换为 REPLACEMENT(参见第 3.5.3 节(Shell 参数展开)),并带有在 REPLACEMENT 中引用所匹配文本的机制。

  • 提供 ${!PREFIX*} 展开,它展开为所有名称以 PREFIX 开头的 Shell 变量的名称(参见第 3.5.3 节(Shell 参数展开))。

    译者注${!PREFIX*}${!PREFIX@} 功能相同,都可列出以指定前缀开头的全部变量名:

    # 译者注示例:列出以指定前缀开头的变量名
    $ foo1=1; foo2=2; echo "${!foo*}"
    foo1 foo2
    
  • Bash 具有使用 ${!word} 的间接变量展开(参见第 3.5.3 节(Shell 参数展开)),并实现了 nameref 变量属性,用于自动的间接变量展开。

  • Bash 包含一组形如 ${var@X} 的参数变换单词展开,其中 X 指定变换方式(参见第 3.5.3 节(Shell 参数展开))。

  • 实现了 POSIX 的 $() 形式命令替换(参见第 3.5.4 节(命令替换)),并优先于 Bourne shell 的反引号(`)形式(后者出于向后兼容也仍然实现)。

  • Bash 实现了一种在当前 Shell 执行环境中运行所括命令的命令替换变体:${COMMAND;}${|COMMAND;}(参见第 3.5.4 节(命令替换))。

  • Bash 具有进程替换功能(参见第 3.5.6 节(进程替换))。

  • Bash 会自动赋值一些变量,提供当前用户(UIDEUIDGROUPS)、当前主机(HOSTTYPEOSTYPEMACHTYPEHOSTNAME)以及正在运行的 Bash 实例(BASHBASH_VERSIONBASH_VERSINFO)的信息。详见第 5.2 节(Bash 变量)。

  • Bash 使用许多 Bourne shell 没有的变量来提供功能、定制 Shell 行为。例如 RANDOMSRANDOMEPOCHSECONDSEPOCHREALTIMETIMEFORMATBASHPIDBASH_XTRACEFDGLOBIGNOREHISTIGNOREBASH_VERSION。完整列表参见第 5.2 节(Bash 变量)。

  • Bash 使用 GLOBSORT Shell 变量控制文件名展开结果的排序方式(参见第 3.5.8 节(文件名展开))。

  • Bash 只用 IFS 变量拆分展开的结果,而不是拆分所有单词(参见第 3.5.7 节(单词拆分))。这堵住了长期存在的 Shell 安全漏洞。

    译者注:传统 Bourne shell 会对所有未加引号的单词按 IFS 重新拆分,包括命令中出现的字面单词,这曾造成大量难以排查的脚本问题。Bash 只对展开结果拆分,字面单词不受 IFS 影响:

    # 译者注示例:IFS 只拆分展开结果,不拆分字面单词
    $ IFS=,; set -- a,b; echo $#
    1
    $ x="a,b"; set -- $x; echo $#
    2
    
  • 文件名展开的方括号表达式用 !^ 来取反括号内的字符集合(参见第 3.5.8 节(文件名展开))。Bourne shell 只使用 !

  • Bash 实现了完整的 POSIX 文件名展开操作符,包括字符类、等价类和排序符号(参见第 3.5.8 节(文件名展开))。

  • 启用 extglob Shell 选项后,Bash 会提供扩展模式匹配功能(参见第 3.5.8.1 节(模式匹配))。

  • globstar Shell 选项将文件名展开扩展为递归扫描目录和子目录以查找匹配的文件名(参见第 3.5.8.1 节(模式匹配))。

  • 在 Bash 中,变量和函数可以同名;sh 不区分这两个命名空间。

  • Bash 函数允许通过 local 内建命令使用局部变量,因此用户可以编写实用的递归函数(参见第 4.2 节(Bash 内建命令))。

  • 对作为输入、输出重定向操作符操作数的文件名,Bash 会执行文件名展开(参见第 3.6 节(重定向))。

  • Bash 包含 <> 重定向操作符,允许以读写方式打开文件;还包含 &> 重定向操作符,将标准输出和标准错误导向同一文件(参见第 3.6 节(重定向))。

  • Bash 包含 <<< 重定向操作符,允许将字符串用作命令的标准输入(参见第 3.6 节(重定向))。

  • Bash 实现了 [n]<&WORD[n]>&WORD 重定向操作符,将一个文件描述符移动到另一个文件描述符。

  • 当某些文件名用于重定向操作符时,Bash 会对它们进行特殊处理(参见第 3.6 节(重定向))。

  • Bash 提供 {VAR}<WORD 功能,让 Shell 为重定向分配文件描述符并赋给 VAR(参见第 3.6 节(重定向))。这一功能可配合多个重定向操作符使用。

  • Bash 可以用重定向操作符打开到任意主机和服务的网络连接(参见第 3.6 节(重定向))。

  • 提供 noclobber 选项,避免输出重定向覆盖已有文件(参见第 4.3.1 节(set 内建命令))。可以用 >| 重定向操作符覆盖 noclobber 的限制。

  • 命令前面的变量赋值只影响该命令本身,即使该命令是内建命令或函数也是如此(参见第 3.7.4 节(环境))。在 sh 中,命令前面的变量赋值一律是全局的,除非该命令是从文件系统执行的。

  • Bash 包含多项支持独立调试器调试 Shell 脚本的功能:变量(BASH_ARGCBASH_ARGVBASH_LINENOBASH_SOURCE)、DEBUGRETURNERR 陷阱、declare -F,以及 caller 内建命令。

  • Bash 实现了类似 csh 的目录栈,并提供 pushdpopddirs 内建命令来操作它(参见第 6.8 节(目录栈))。Bash 还通过 DIRSTACK Shell 变量的值来呈现目录栈。

  • Bash 允许函数覆盖同名的内建命令,并可通过 builtincommand 内建命令在函数内访问该内建命令的功能(参见第 4.2 节(Bash 内建命令))。

    译者注:命令查找顺序为:别名(展开阶段)→ Shell 函数 → 内建命令 → $PATH 中的外部命令。因此函数可以覆盖同名内建命令;若想在函数内调用被覆盖的内建命令,可用 commandbuiltin 绕过:

    # 译者注示例:函数覆盖内建命令,用 command 调用原内建命令
    $ cd() { echo "覆盖生效:$*"; command cd "$@"; }
    $ cd /tmp
    覆盖生效:/tmp
    $ pwd
    /tmp
    
  • Bash 包含 caller 内建命令(参见第 4.2 节(Bash 内建命令)),它显示任何活动子例程调用(Shell 函数,或用 .source 内建命令执行的脚本)的上下文。这为 Bash 调试器提供支持。

  • Bash 的 cdpwd 内建命令(参见第 4.1 节(Bourne Shell 内建命令))都支持 -L-P 选项,用于在逻辑模式与物理模式之间切换。

  • command 内建命令允许在执行命令查找时有选择地跳过 Shell 函数(参见第 4.2 节(Bash 内建命令))。

  • Bash 用 declare 内建命令修改全部变量和函数属性,并为变量赋值。

  • disown 内建命令可以从 Shell 内部的作业表中删除作业(参见第 7.2 节(作业控制内建命令)),或在 Shell 因收到 SIGHUP 而退出时抑制向作业发送 SIGHUP

  • enable 内建命令(参见第 4.2 节(Bash 内建命令))可以启用或禁用单个内建命令,并支持从共享对象动态加载内建命令。

  • Bash 的 exec 内建命令带有额外选项,允许用户控制传给被执行命令的环境内容,以及命令的第零个参数是什么(参见第 4.1 节(Bourne Shell 内建命令))。

  • 可以用 export -f 通过环境将 Shell 函数导出到子进程(参见第 3.3 节(Shell 函数))。

  • Bash 的 exportreadonly 内建命令(参见第 4.1 节(Bourne Shell 内建命令))可以带 -f 选项作用于 Shell 函数,带 -p 选项以可作为 Shell 输入重用的格式显示设置了各种属性的变量,带 -n 选项移除各种变量属性,以及带 name=value 参数同时设置变量属性和值。

  • Bash 的 hash 内建命令允许用 hash -p 将某个名称与任意文件名关联起来,即使该文件名无法通过搜索 $PATH 找到(参见第 4.1 节(Bourne Shell 内建命令))。

  • Bash 包含用于快速查阅 Shell 功能的 help 内建命令(参见第 4.2 节(Bash 内建命令))。

  • Bash 包含 mapfile 内建命令,用于将文件内容快速读入索引数组变量(参见第 4.2 节(Bash 内建命令))。

  • 提供 printf 内建命令显示格式化输出(参见第 4.2 节(Bash 内建命令)),它还有额外的自定义格式说明符,以及把格式化输出直接赋给 Shell 变量的选项。

  • Bash 的 read 内建命令(参见第 4.2 节(Bash 内建命令))带 -r 选项时可以读取以 \ 结尾的行;如果没有提供非选项参数,则默认使用 REPLY 变量。

  • read 内建命令(参见第 4.2 节(Bash 内建命令))用 -p 选项接受提示字符串,在给定 -e-E 选项时使用 Readline 获取输入行,并可用 -i 选项向输入行中插入文本。read 内建命令还有其他控制输入的选项:-s 选项在读取输入字符时关闭回显,-t 选项允许 read 在指定秒数内没有输入时超时,-n 选项只读取指定数量的字符而不是一整行,-d 选项则一直读取到某个特定字符而不是换行符。

  • 可以用 return 内建命令中止用 .source 内建命令执行的脚本(参见第 4.1 节(Bourne Shell 内建命令))。

  • Bash 有更多可用 set 内建命令控制的可选行为(参见第 4.3.1 节(set 内建命令))。

  • -xxtrace)选项在执行追踪时显示简单命令以外的其他命令(参见第 4.3.1 节(set 内建命令))。

  • Bash 包含 shopt 内建命令,用于更精细地控制 Shell 的可选功能(参见第 4.3.2 节(shopt 内建命令)),并允许在调用 Shell 时设置和取消这些选项(参见第 6.1 节(调用 Bash))。

  • test 内建命令(参见第 4.1 节(Bourne Shell 内建命令))略有不同,它实现了 POSIX 算法,该算法根据参数个数确定行为。

  • trap 内建命令(参见第 4.1 节(Bourne Shell 内建命令))允许指定 DEBUG 伪信号,与 EXIT 类似。设置了 DEBUG 陷阱的命令会在每个简单命令、for 命令、case 命令、select 命令、每个算术 for 命令之前执行,也会在 Shell 函数中第一个命令执行之前执行。除非函数带有 trace 属性,或者用 shopt 内建命令启用了 functrace 选项,否则 Shell 函数不继承 DEBUG 陷阱。extdebug Shell 选项对 DEBUG 陷阱还有额外影响。

    trap 内建命令(参见第 4.1 节(Bourne Shell 内建命令))允许指定 ERR 伪信号,与 EXITDEBUG 类似。设置了 ERR 陷阱的命令在简单命令失败后执行,有少数例外。除非启用 set 内建命令的 -o errtrace 选项,否则 Shell 函数不继承 ERR 陷阱。

    trap 内建命令(参见第 4.1 节(Bourne Shell 内建命令))允许指定 RETURN 伪信号,与 EXITDEBUG 类似。设置了 RETURN 陷阱的命令会在 Shell 函数或用 .source 执行的脚本返回之后、执行恢复之前执行。除非函数带有 trace 属性,或者用 shopt 内建命令启用了 functrace 选项,否则 Shell 函数不继承 RETURN 陷阱。

  • Bash 的 type 内建命令功能更全面,会给出关于所查名称的更多信息(参见第 4.2 节(Bash 内建命令))。

  • ulimit 内建命令可以控制更多的每进程资源(参见第 4.2 节(Bash 内建命令))。

  • Bash 的 umask 内建命令用 -p 选项以 umask 命令的形式显示输出,该输出可直接作为输入重用(参见第 4.1 节(Bourne Shell 内建命令))。

  • Bash 的 wait 内建命令带 -n 选项,等待下一个子进程退出,也可以从提供的作业列表中指定;带 -p 选项可将已终止子进程的信息存入 Shell 变量。

  • SVR4.2 shell 以 jsh 方式调用时行为不同(它会开启作业控制)。

  • SVR4.2 shell 有两个与特权相关的内建命令(mldmodepriv),Bash 中没有。

  • Bash 没有 stopnewgrp 内建命令。

  • Bash 不使用 SHACCT 变量,也不进行 Shell 记账(shell accounting)。

  • SVR4.2 的 sh 使用 TIMEOUT 变量,相当于 Bash 使用 TMOUT

更多 Bash 独有的功能可参见第 6 章(Bash 功能)。

B.1 与 SVR4.2 Shell 的实现差异

由于 Bash 是完全重新实现的,它没有 SVR4.2 shell 的许多局限。例如:

  • 在向 ifwhile 语句等 Shell 控制结构进行重定向(输入或输出)时,Bash 不会派生子 Shell。

  • Bash 不允许不配对的引号。SVR4.2 shell 在某种情况下会在 EOF 处悄悄补上一个需要的结束引号。这可能是某些难以发现的错误的根源。

  • SVR4.2 shell 使用一种基于捕获 SIGSEGV 的繁复内存管理方案。如果 Shell 是从一个屏蔽了 SIGSEGV 的进程启动的(例如通过 C 库函数 system() 调用),它就会严重失常。

  • 出于一项值得商榷的安全举措,SVR4.2 shell 在不带 -p 选项调用时,如果其真实和有效 UID、GID 小于某个神奇的阈值(通常是 100),就会更改它们。这可能导致意想不到的结果。

  • SVR4.2 shell 不允许用户捕获 SIGSEGVSIGALRMSIGCHLD

  • SVR4.2 shell 不允许取消设置 IFSMAILCHECKPATHPS1PS2 变量。

  • SVR4.2 shell 把 ^ 当作 | 的等价物,这一点未在文档中说明。

  • Bash 允许在调用时使用多个选项参数(-x -v);SVR4.2 shell 只允许一个选项参数(-xv)。事实上,某些版本的 shell 在第二个参数以 - 开头时会转储核心(dump core)。

  • SVR4.2 shell 在任一内建命令失败时都会退出脚本;Bash 只在某个 POSIX 特殊内建命令失败时才退出脚本,而且仅限于 POSIX 标准列举的某些失败情况。

  • 如果启用了 lastpipe 选项并且作业控制未激活,Bash 会在当前 Shell 执行环境中运行管道的最后一个元素。

    译者注:在非交互式 Shell 中开启 lastpipe 后,管道中读取的值在管道结束后仍然可用(交互式 Shell 因启用了作业控制,lastpipe 不生效):

    # 译者注示例:lastpipe(需在非交互式 Shell 中测试)
    $ shopt -s lastpipe; printf 'abc\n' | read -r x; echo "$x"
    abc
    

附录 C GNU 自由文档许可证(GNU Free Documentation License)

以下为许可证英文原文,按官方文本保留,不提供非官方译文。

Version 1.3, 3 November 2008

Copyright © 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
http://fsf.org/

Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.

0. PREAMBLE

The purpose of this License is to make a manual, textbook, or other
functional and useful document “free” in the sense of freedom: to
assure everyone the effective freedom to copy and redistribute it,
with or without modifying it, either commercially or
noncommercially. Secondarily, this License preserves for the
author and publisher a way to get credit for their work, while not
being considered responsible for modifications made by others.

This License is a kind of "copyleft", which means that derivative
works of the document must themselves be free in the same sense.
It complements the GNU General Public License, which is a copyleft
license designed for free software.

We have designed this License in order to use it for manuals for
free software, because free software needs free documentation: a
free program should come with manuals providing the same freedoms
that the software does. But this License is not limited to
software manuals; it can be used for any textual work, regardless
of subject matter or whether it is published as a printed book. We
recommend this License principally for works whose purpose is
instruction or reference.

1. APPLICABILITY AND DEFINITIONS

This License applies to any manual or other work, in any medium,
that contains a notice placed by the copyright holder saying it can
be distributed under the terms of this License. Such a notice
grants a world-wide, royalty-free license, unlimited in duration,
to use that work under the conditions stated herein. The
"Document", below, refers to any such manual or work. Any member
of the public is a licensee, and is addressed as "you". You accept
the license if you copy, modify or distribute the work in a way
requiring permission under copyright law.

A "Modified Version" of the Document means any work containing the
Document or a portion of it, either copied verbatim, or with
modifications and/or translated into another language.

A "Secondary Section" is a named appendix or a front-matter section
of the Document that deals exclusively with the relationship of the
publishers or authors of the Document to the Document's overall
subject (or to related matters) and contains nothing that could
fall directly within that overall subject. (Thus, if the Document
is in part a textbook of mathematics, a Secondary Section may not
explain any mathematics.) The relationship could be a matter of
historical connection with the subject or with related matters, or
of legal, commercial, philosophical, ethical or political position
regarding them.

The "Invariant Sections" are certain Secondary Sections whose
titles are designated, as being those of Invariant Sections, in the
notice that says that the Document is released under this License.
If a section does not fit the above definition of Secondary then it
is not allowed to be designated as Invariant. The Document may
contain zero Invariant Sections. If the Document does not identify
any Invariant Sections then there are none.

The "Cover Texts" are certain short passages of text that are
listed, as Front-Cover Texts or Back-Cover Texts, in the notice
that says that the Document is released under this License. A
Front-Cover Text may be at most 5 words, and a Back-Cover Text may
be at most 25 words.

A "Transparent" copy of the Document means a machine-readable copy,
represented in a format whose specification is available to the
general public, that is suitable for revising the document
straightforwardly with generic text editors or (for images composed
of pixels) generic paint programs or (for drawings) some widely
available drawing editor, and that is suitable for input to text
formatters or for automatic translation to a variety of formats
suitable for input to text formatters. A copy made in an otherwise
Transparent file format whose markup, or absence of markup, has
been arranged to thwart or discourage subsequent modification by
readers is not Transparent. An image format is not Transparent if
used for any substantial amount of text. A copy that is not
"Transparent" is called "Opaque".

Examples of suitable formats for Transparent copies include plain
ASCII without markup, Texinfo input format, LaTeX input format,
SGML or XML using a publicly available DTD, and standard-conforming
simple HTML, PostScript or PDF designed for human modification.
Examples of transparent image formats include PNG, XCF and JPG.
Opaque formats include proprietary formats that can be read and
edited only by proprietary word processors, SGML or XML for which
the DTD and/or processing tools are not generally available, and
the machine-generated HTML, PostScript or PDF produced by some word
processors for output purposes only.

The "Title Page" means, for a printed book, the title page itself,
plus such following pages as are needed to hold, legibly, the
material this License requires to appear in the title page. For
works in formats which do not have any title page as such, "Title
Page" means the text near the most prominent appearance of the
work's title, preceding the beginning of the body of the text.

The "publisher" means any person or entity that distributes copies
of the Document to the public.

A section "Entitled XYZ" means a named subunit of the Document
whose title either is precisely XYZ or contains XYZ in parentheses
following text that translates XYZ in another language. (Here XYZ
stands for a specific section name mentioned below, such as
"Acknowledgements", "Dedications", "Endorsements", or "History".)
To "Preserve the Title" of such a section when you modify the
Document means that it remains a section "Entitled XYZ" according
to this definition.

The Document may include Warranty Disclaimers next to the notice
which states that this License applies to the Document. These
Warranty Disclaimers are considered to be included by reference in
this License, but only as regards disclaiming warranties: any other
implication that these Warranty Disclaimers may have is void and
has no effect on the meaning of this License.

2. VERBATIM COPYING

You may copy and distribute the Document in any medium, either
commercially or noncommercially, provided that this License, the
copyright notices, and the license notice saying this License
applies to the Document are reproduced in all copies, and that you
add no other conditions whatsoever to those of this License. You
may not use technical measures to obstruct or control the reading
or further copying of the copies you make or distribute. However,
you may accept compensation in exchange for copies. If you
distribute a large enough number of copies you must also follow the
conditions in section 3.

You may also lend copies, under the same conditions stated above,
and you may publicly display copies.

3. COPYING IN QUANTITY

If you publish printed copies (or copies in media that commonly
have printed covers) of the Document, numbering more than 100, and
the Document's license notice requires Cover Texts, you must
enclose the copies in covers that carry, clearly and legibly, all
these Cover Texts: Front-Cover Texts on the front cover, and
Back-Cover Texts on the back cover. Both covers must also clearly
and legibly identify you as the publisher of these copies. The
front cover must present the full title with all words of the title
equally prominent and visible. You may add other material on the
covers in addition. Copying with changes limited to the covers, as
long as they preserve the title of the Document and satisfy these
conditions, can be treated as verbatim copying in other respects.

If the required texts for either cover are too voluminous to fit
legibly, you should put the first ones listed (as many as fit
reasonably) on the actual cover, and continue the rest onto
adjacent pages.

If you publish or distribute Opaque copies of the Document
numbering more than 100, you must either include a machine-readable
Transparent copy along with each Opaque copy, or state in or with
each Opaque copy a computer-network location from which the general
network-using public has access to download using public-standard
network protocols a complete Transparent copy of the Document, free
of added material. If you use the latter option, you must take
reasonably prudent steps, when you begin distribution of Opaque
copies in quantity, to ensure that this Transparent copy will
remain thus accessible at the stated location until at least one
year after the last time you distribute an Opaque copy (directly or
through your agents or retailers) of that edition to the public.

It is requested, but not required, that you contact the authors of
the Document well before redistributing any large number of copies,
to give them a chance to provide you with an updated version of the
Document.

4. MODIFICATIONS

You may copy and distribute a Modified Version of the Document
under the conditions of sections 2 and 3 above, provided that you
release the Modified Version under precisely this License, with the
Modified Version filling the role of the Document, thus licensing
distribution and modification of the Modified Version to whoever
possesses a copy of it. In addition, you must do these things in
the Modified Version:

A. Use in the Title Page (and on the covers, if any) a title
distinct from that of the Document, and from those of previous
versions (which should, if there were any, be listed in the
History section of the Document). You may use the same title
as a previous version if the original publisher of that
version gives permission.

B. List on the Title Page, as authors, one or more persons or
entities responsible for authorship of the modifications in
the Modified Version, together with at least five of the
principal authors of the Document (all of its principal
authors, if it has fewer than five), unless they release you
from this requirement.

C. State on the Title page the name of the publisher of the
Modified Version, as the publisher.

D. Preserve all the copyright notices of the Document.

E. Add an appropriate copyright notice for your modifications
adjacent to the other copyright notices.

F. Include, immediately after the copyright notices, a license
notice giving the public permission to use the Modified
Version under the terms of this License, in the form shown in
the Addendum below.

G. Preserve in that license notice the full lists of Invariant
Sections and required Cover Texts given in the Document's
license notice.

H. Include an unaltered copy of this License.

I. Preserve the section Entitled "History", Preserve its Title,
and add to it an item stating at least the title, year, new
authors, and publisher of the Modified Version as given on the
Title Page. If there is no section Entitled "History" in the
Document, create one stating the title, year, authors, and
publisher of the Document as given on its Title Page, then add
an item describing the Modified Version as stated in the
previous sentence.

J. Preserve the network location, if any, given in the Document
for public access to a Transparent copy of the Document, and
likewise the network locations given in the Document for
previous versions it was based on. These may be placed in the
"History" section. You may omit a network location for a work
that was published at least four years before the Document
itself, or if the original publisher of the version it refers
to gives permission.

K. For any section Entitled "Acknowledgements" or "Dedications",
Preserve the Title of the section, and preserve in the section
all the substance and tone of each of the contributor
acknowledgements and/or dedications given therein.

L. Preserve all the Invariant Sections of the Document, unaltered
in their text and in their titles. Section numbers or the
equivalent are not considered part of the section titles.

M. Delete any section Entitled "Endorsements". Such a section
may not be included in the Modified Version.

N. Do not retitle any existing section to be Entitled
"Endorsements" or to conflict in title with any Invariant
Section.

O. Preserve any Warranty Disclaimers.

If the Modified Version includes new front-matter sections or
appendices that qualify as Secondary Sections and contain no
material copied from the Document, you may at your option designate
some or all of these sections as invariant. To do this, add their
titles to the list of Invariant Sections in the Modified Version's
license notice. These titles must be distinct from any other
section titles.

You may add a section Entitled "Endorsements", provided it contains
nothing but endorsements of your Modified Version by various
parties--for example, statements of peer review or that the text
has been approved by an organization as the authoritative
definition of a standard.

You may add a passage of up to five words as a Front-Cover Text,
and a passage of up to 25 words as a Back-Cover Text, to the end of
the list of Cover Texts in the Modified Version. Only one passage
of Front-Cover Text and one of Back-Cover Text may be added by (or
through arrangements made by) any one entity. If the Document
already includes a cover text for the same cover, previously added
by you or by arrangement made by the same entity you are acting on
behalf of, you may not add another; but you may replace the old
one, on explicit permission from the previous publisher that added
the old one.

The author(s) and publisher(s) of the Document do not by this
License give permission to use their names for publicity for or to
assert or imply endorsement of any Modified Version.

5. COMBINING DOCUMENTS

You may combine the Document with other documents released under
this License, under the terms defined in section 4 above for
modified versions, provided that you include in the combination all
of the Invariant Sections of all of the original documents,
unmodified, and list them all as Invariant Sections of your
combined work in its license notice, and that you preserve all
their Warranty Disclaimers.

The combined work need only contain one copy of this License, and
multiple identical Invariant Sections may be replaced with a single
copy. If there are multiple Invariant Sections with the same name
but different contents, make the title of each such section unique
by adding at the end of it, in parentheses, the name of the
original author or publisher of that section if known, or else a
unique number. Make the same adjustment to the section titles in
the list of Invariant Sections in the license notice of the
combined work.

In the combination, you must combine any sections Entitled
"History" in the various original documents, forming one section
Entitled "History"; likewise combine any sections Entitled
"Acknowledgements", and any sections Entitled "Dedications". You
must delete all sections Entitled "Endorsements."

6. COLLECTIONS OF DOCUMENTS

You may make a collection consisting of the Document and other
documents released under this License, and replace the individual
copies of this License in the various documents with a single copy
that is included in the collection, provided that you follow the
rules of this License for verbatim copying of each of the documents
in all other respects.

You may extract a single document from such a collection, and
distribute it individually under this License, provided you insert
a copy of this License into the extracted document, and follow this
License in all other respects regarding verbatim copying of that
document.

7. AGGREGATION WITH INDEPENDENT WORKS

A compilation of the Document or its derivatives with other
separate and independent documents or works, in or on a volume of a
storage or distribution medium, is called an "aggregate" if the
copyright resulting from the compilation is not used to limit the
legal rights of the compilation's users beyond what the individual
works permit. When the Document is included in an aggregate, this
License does not apply to the other works in the aggregate which
are not themselves derivative works of the Document.

If the Cover Text requirement of section 3 is applicable to these
copies of the Document, then if the Document is less than one half
of the entire aggregate, the Document's Cover Texts may be placed
on covers that bracket the Document within the aggregate, or the
electronic equivalent of covers if the Document is in electronic
form. Otherwise they must appear on printed covers that bracket
the whole aggregate.

8. TRANSLATION

Translation is considered a kind of modification, so you may
distribute translations of the Document under the terms of section
4. Replacing Invariant Sections with translations requires special
permission from their copyright holders, but you may include
translations of some or all Invariant Sections in addition to the
original versions of these Invariant Sections. You may include a
translation of this License, and all the license notices in the
Document, and any Warranty Disclaimers, provided that you also
include the original English version of this License and the
original versions of those notices and disclaimers. In case of a
disagreement between the translation and the original version of
this License or a notice or disclaimer, the original version will
prevail.

If a section in the Document is Entitled "Acknowledgements",
"Dedications", or "History", the requirement (section 4) to
Preserve its Title (section 1) will typically require changing the
actual title.

9. TERMINATION

You may not copy, modify, sublicense, or distribute the Document
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense, or distribute it is void,
and will automatically terminate your rights under this License.

However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the
copyright holder fails to notify you of the violation by some
reasonable means prior to 60 days after the cessation.

Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from
that copyright holder, and you cure the violation prior to 30 days
after your receipt of the notice.

Termination of your rights under this section does not terminate
the licenses of parties who have received copies or rights from you
under this License. If your rights have been terminated and not
permanently reinstated, receipt of a copy of some or all of the
same material does not give you any rights to use it.

10. FUTURE REVISIONS OF THIS LICENSE

The Free Software Foundation may publish new, revised versions of
the GNU Free Documentation License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns. See
http://www.gnu.org/copyleft/.

Each version of the License is given a distinguishing version
number. If the Document specifies that a particular numbered
version of this License "or any later version" applies to it, you
have the option of following the terms and conditions either of
that specified version or of any later version that has been
published (not as a draft) by the Free Software Foundation. If the
Document does not specify a version number of this License, you may
choose any version ever published (not as a draft) by the Free
Software Foundation. If the Document specifies that a proxy can
decide which future versions of this License can be used, that
proxy's public statement of acceptance of a version permanently
authorizes you to choose that version for the Document.

11. RELICENSING

"Massive Multiauthor Collaboration Site" (or "MMC Site") means any
World Wide Web server that publishes copyrightable works and also
provides prominent facilities for anybody to edit those works. A
public wiki that anybody can edit is an example of such a server.
A "Massive Multiauthor Collaboration" (or "MMC") contained in the
site means any set of copyrightable works thus published on the MMC
site.

"CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0
license published by Creative Commons Corporation, a not-for-profit
corporation with a principal place of business in San Francisco,
California, as well as future copyleft versions of that license
published by that same organization.

"Incorporate" means to publish or republish a Document, in whole or
in part, as part of another Document.

An MMC is "eligible for relicensing" if it is licensed under this
License, and if all works that were first published under this
License somewhere other than this MMC, and subsequently
incorporated in whole or in part into the MMC, (1) had no cover
texts or invariant sections, and (2) were thus incorporated prior
to November 1, 2008.

The operator of an MMC Site may republish an MMC contained in the
site under CC-BY-SA on the same site at any time before August 1,
2009, provided the MMC is eligible for relicensing.

ADDENDUM: How to use this License for your documents

To use this License in a document you have written, include a copy of
the License in the document and put the following copyright and license
notices just after the title page:

       Copyright (C)  YEAR  YOUR NAME.
       Permission is granted to copy, distribute and/or modify this document
       under the terms of the GNU Free Documentation License, Version 1.3
       or any later version published by the Free Software Foundation;
       with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
       Texts.  A copy of the license is included in the section entitled ``GNU
       Free Documentation License''.

If you have Invariant Sections, Front-Cover Texts and Back-Cover
Texts, replace the "with...Texts." line with this:

         with the Invariant Sections being LIST THEIR TITLES, with
         the Front-Cover Texts being LIST, and with the Back-Cover Texts
         being LIST.

If you have Invariant Sections without Cover Texts, or some other
combination of the three, merge those two alternatives to suit the
situation.

If your document contains nontrivial examples of program code, we
recommend releasing these examples in parallel under your choice of free
software license, such as the GNU General Public License, to permit
their use in free software.

附录 D 索引

索引条目以英文关键字排列,便于按原词检索。

D.1 内建命令索引

  • ::: Bourne Shell Builtins. (line 3278)
  • .: Bourne Shell Builtins. (line 3284)
  • [: Bourne Shell Builtins. (line 3606)
  • alias: Bash Builtins. (line 3828)
  • bg: Job Control Builtins. (line 8002)
  • bind: Bash Builtins. (line 3841)
  • break: Bourne Shell Builtins. (line 3314)
  • builtin: Bash Builtins. (line 3950)
  • caller: Bash Builtins. (line 3959)
  • cd: Bourne Shell Builtins. (line 3322)
  • command: Bash Builtins. (line 3976)
  • compgen: Programmable Completion Builtins. (line 9996)
  • complete: Programmable Completion Builtins. (line 10021)
  • compopt: Programmable Completion Builtins. (line 10242)
  • continue: Bourne Shell Builtins. (line 3373)
  • declare: Bash Builtins. (line 3996)
  • dirs: Directory Stack Builtins. (line 7098)
  • disown: Job Control Builtins. (line 8115)
  • echo: Bash Builtins. (line 4101)
  • enable: Bash Builtins. (line 4154)
  • eval: Bourne Shell Builtins. (line 3382)
  • exec: Bourne Shell Builtins. (line 3390)
  • exit: Bourne Shell Builtins. (line 3412)
  • export: Bourne Shell Builtins. (line 3419)
  • false: Bourne Shell Builtins. (line 3442)
  • fc: Bash History Builtins. (line 10450)
  • fg: Job Control Builtins. (line 8012)
  • getopts: Bourne Shell Builtins. (line 3447)
  • hash: Bourne Shell Builtins. (line 3499)
  • help: Bash Builtins. (line 4191)
  • history: Bash History Builtins. (line 10499)
  • jobs: Job Control Builtins. (line 8023)
  • kill: Job Control Builtins. (line 8056)
  • let: Bash Builtins. (line 4220)
  • local: Bash Builtins. (line 4229)
  • logout: Bash Builtins. (line 4254)
  • mapfile: Bash Builtins. (line 4259)
  • popd: Directory Stack Builtins. (line 7128)
  • printf: Bash Builtins. (line 4304)
  • pushd: Directory Stack Builtins. (line 7162)
  • pwd: Bourne Shell Builtins. (line 3531)
  • read: Bash Builtins. (line 4374)
  • readarray: Bash Builtins. (line 4485)
  • readonly: Bourne Shell Builtins. (line 3543)
  • return: Bourne Shell Builtins. (line 3568)
  • set: The Set Builtin. (line 4667)
  • shift: Bourne Shell Builtins. (line 3593)
  • shopt: The Shopt Builtin. (line 4962)
  • source: Bash Builtins. (line 4494)
  • suspend: Job Control Builtins. (line 8134)
  • test: Bourne Shell Builtins. (line 3606)
  • times: Bourne Shell Builtins. (line 3706)
  • trap: Bourne Shell Builtins. (line 3712)
  • true: Bourne Shell Builtins. (line 3778)
  • type: Bash Builtins. (line 4499)
  • typeset: Bash Builtins. (line 4536)
  • ulimit: Bash Builtins. (line 4542)
  • umask: Bourne Shell Builtins. (line 3783)
  • unalias: Bash Builtins. (line 4650)
  • unset: Bourne Shell Builtins. (line 3801)
  • wait: Job Control Builtins. (line 8081)

D.2 保留字索引

  • !: Pipelines. (line 673)
  • [[: Conditional Constructs. (line 973)
  • ]]: Conditional Constructs. (line 973)
  • {: Command Grouping. (line 1173)
  • }: Command Grouping. (line 1173)
  • case: Conditional Constructs. (line 873)
  • do: Looping Constructs. (line 797)
  • done: Looping Constructs. (line 797)
  • elif: Conditional Constructs. (line 852)
  • else: Conditional Constructs. (line 852)
  • esac: Conditional Constructs. (line 873)
  • fi: Conditional Constructs. (line 852)
  • for: Looping Constructs. (line 817)
  • function: Shell Functions. (line 1276)
  • if: Conditional Constructs. (line 852)
  • in: Conditional Constructs. (line 873)
  • select: Conditional Constructs. (line 929)
  • then: Conditional Constructs. (line 852)
  • time: Pipelines. (line 673)
  • until: Looping Constructs. (line 797)
  • while: Looping Constructs. (line 807)

D.3 参数与变量索引

  • _: Bash Variables. (line 5437)
  • -: Special Parameters. (line 1570)
  • !: Special Parameters. (line 1579)
  • ?: Special Parameters. (line 1566)
  • @: Special Parameters. (line 1545)
  • *: Special Parameters. (line 1532)
  • #: Special Parameters. (line 1563)
  • $: Special Parameters. (line 1575)
  • $_: Bash Variables. (line 5438)
  • $-: Special Parameters. (line 1571)
  • $!: Special Parameters. (line 1580)
  • $?: Special Parameters. (line 1567)
  • $@: Special Parameters. (line 1546)
  • $*: Special Parameters. (line 1533)
  • $#: Special Parameters. (line 1564)
  • $$: Special Parameters. (line 1576)
  • $0: Special Parameters. (line 1585)
  • 0: Special Parameters. (line 1584)
  • active-region-end-color: Readline Init File Syntax. (line 8476)
  • active-region-start-color: Readline Init File Syntax. (line 8463)
  • auto_resume: Job Control Variables. (line 8148)
  • BASH: Bash Variables. (line 5448)
  • BASH_ALIASES: Bash Variables. (line 5468)
  • BASH_ARGC: Bash Variables. (line 5477)
  • BASH_ARGV: Bash Variables. (line 5491)
  • BASH_ARGV0: Bash Variables. (line 5504)
  • BASH_CMDS: Bash Variables. (line 5512)
  • BASH_COMMAND: Bash Variables. (line 5521)
  • BASH_COMPAT: Bash Variables. (line 5528)
  • BASH_ENV: Bash Variables. (line 5544)
  • BASH_EXECUTION_STRING: Bash Variables. (line 5550)
  • BASH_LINENO: Bash Variables. (line 5553)
  • BASH_LOADABLES_PATH: Bash Variables. (line 5563)
  • BASH_MONOSECONDS: Bash Variables. (line 5567)
  • BASH_REMATCH: Bash Variables. (line 5574)
  • BASH_SOURCE: Bash Variables. (line 5582)
  • BASH_SUBSHELL: Bash Variables. (line 5590)
  • BASH_TRAPSIG: Bash Variables. (line 5596)
  • BASH_VERSINFO: Bash Variables. (line 5602)
  • BASH_VERSION: Bash Variables. (line 5625)
  • BASH_XTRACEFD: Bash Variables. (line 5629)
  • BASHOPTS: Bash Variables. (line 5451)
  • BASHPID: Bash Variables. (line 5461)
  • bell-style: Readline Init File Syntax. (line 8489)
  • bind-tty-special-chars: Readline Init File Syntax. (line 8496)
  • blink-matching-paren: Readline Init File Syntax. (line 8504)
  • CDPATH: Bourne Shell Variables. (line 5374)
  • CHILD_MAX: Bash Variables. (line 5641)
  • colored-completion-prefix: Readline Init File Syntax. (line 8509)
  • colored-stats: Readline Init File Syntax. (line 8519)
  • COLUMNS: Bash Variables. (line 5648)
  • comment-begin: Readline Init File Syntax. (line 8525)
  • COMP_CWORD: Bash Variables. (line 5654)
  • COMP_KEY: Bash Variables. (line 5660)
  • COMP_LINE: Bash Variables. (line 5666)
  • COMP_POINT: Bash Variables. (line 5671)
  • COMP_TYPE: Bash Variables. (line 5679)
  • COMP_WORDBREAKS: Bash Variables. (line 5689)
  • COMP_WORDS: Bash Variables. (line 5695)
  • completion-display-width: Readline Init File Syntax. (line 8529)
  • completion-ignore-case: Readline Init File Syntax. (line 8536)
  • completion-map-case: Readline Init File Syntax. (line 8541)
  • completion-prefix-display-length: Readline Init File Syntax. (line 8547)
  • completion-query-items: Readline Init File Syntax. (line 8556)
  • COMPREPLY: Bash Variables. (line 5702)
  • convert-meta: Readline Init File Syntax. (line 8567)
  • COPROC: Bash Variables. (line 5708)
  • DIRSTACK: Bash Variables. (line 5712)
  • disable-completion: Readline Init File Syntax. (line 8579)
  • echo-control-characters: Readline Init File Syntax. (line 8584)
  • editing-mode: Readline Init File Syntax. (line 8589)
  • EMACS: Bash Variables. (line 5722)
  • emacs-mode-string: Readline Init File Syntax. (line 8595)
  • enable-active-region The: Readline Init File Syntax. (line 8605)
  • enable-bracketed-paste: Readline Init File Syntax. (line 8618)
  • enable-keypad: Readline Init File Syntax. (line 8627)
  • enable-meta-key: Readline Init File Syntax. (line 8632)
  • ENV: Bash Variables. (line 5727)
  • EPOCHREALTIME: Bash Variables. (line 5732)
  • EPOCHSECONDS: Bash Variables. (line 5740)
  • EUID: Bash Variables. (line 5747)
  • EXECIGNORE: Bash Variables. (line 5751)
  • expand-tilde: Readline Init File Syntax. (line 8642)
  • FCEDIT: Bash Variables. (line 5763)
  • FIGNORE: Bash Variables. (line 5766)
  • force-meta-prefix: Readline Init File Syntax. (line 8646)
  • FUNCNAME: Bash Variables. (line 5772)
  • FUNCNEST: Bash Variables. (line 5789)
  • GLOBIGNORE: Bash Variables. (line 5794)
  • GLOBSORT: Bash Variables. (line 5801)
  • GROUPS: Bash Variables. (line 5839)
  • histchars: Bash Variables. (line 5845)
  • HISTCMD: Bash Variables. (line 5861)
  • HISTCONTROL: Bash Variables. (line 5867)
  • HISTFILE: Bash Variables. (line 5885)
  • HISTFILESIZE: Bash Variables. (line 5891)
  • HISTIGNORE: Bash Variables. (line 5905)
  • history-preserve-point: Readline Init File Syntax. (line 8659)
  • history-size: Readline Init File Syntax. (line 8665)
  • HISTSIZE: Bash Variables. (line 5929)
  • HISTTIMEFORMAT: Bash Variables. (line 5936)
  • HOME: Bourne Shell Variables. (line 5378)
  • horizontal-scroll-mode: Readline Init File Syntax. (line 8675)
  • HOSTFILE: Bash Variables. (line 5945)
  • HOSTNAME: Bash Variables. (line 5956)
  • HOSTTYPE: Bash Variables. (line 5959)
  • IFS: Bourne Shell Variables. (line 5383)
  • IGNOREEOF: Bash Variables. (line 5962)
  • input-meta: Readline Init File Syntax. (line 8683)
  • INPUTRC: Bash Variables. (line 5971)
  • INSIDE_EMACS: Bash Variables. (line 5975)
  • isearch-terminators: Readline Init File Syntax. (line 8694)
  • keymap: Readline Init File Syntax. (line 8701)
  • LANG: Creating Internationalized Scripts. (line 575)
  • LANG <1>: Bash Variables. (line 5981)
  • LC_ALL: Bash Variables. (line 5985)
  • LC_COLLATE: Bash Variables. (line 5989)
  • LC_CTYPE: Bash Variables. (line 5995)
  • LC_MESSAGES: Creating Internationalized Scripts. (line 575)
  • LC_MESSAGES <1>: Bash Variables. (line 6000)
  • LC_NUMERIC: Bash Variables. (line 6004)
  • LC_TIME: Bash Variables. (line 6008)
  • LINENO: Bash Variables. (line 6012)
  • LINES: Bash Variables. (line 6019)
  • MACHTYPE: Bash Variables. (line 6025)
  • MAIL: Bourne Shell Variables. (line 5389)
  • MAILCHECK: Bash Variables. (line 6029)
  • MAILPATH: Bourne Shell Variables. (line 5394)
  • MAPFILE: Bash Variables. (line 6037)
  • mark-modified-lines: Readline Init File Syntax. (line 8731)
  • mark-symlinked-directories: Readline Init File Syntax. (line 8736)
  • match-hidden-files: Readline Init File Syntax. (line 8741)
  • menu-complete-display-prefix: Readline Init File Syntax. (line 8748)
  • meta-flag: Readline Init File Syntax. (line 8683)
  • OLDPWD: Bash Variables. (line 6041)
  • OPTARG: Bourne Shell Variables. (line 5401)
  • OPTERR: Bash Variables. (line 6044)
  • OPTIND: Bourne Shell Variables. (line 5405)
  • OSTYPE: Bash Variables. (line 6049)
  • output-meta: Readline Init File Syntax. (line 8753)
  • page-completions: Readline Init File Syntax. (line 8762)
  • PATH: Bourne Shell Variables. (line 5409)
  • PIPESTATUS: Bash Variables. (line 6052)
  • POSIXLY_CORRECT: Bash Variables. (line 6062)
  • PPID: Bash Variables. (line 6072)
  • PROMPT_COMMAND: Bash Variables. (line 6076)
  • PROMPT_DIRTRIM: Bash Variables. (line 6082)
  • PS0: Bash Variables. (line 6088)
  • PS1: Bourne Shell Variables. (line 5418)
  • PS2: Bourne Shell Variables. (line 5423)
  • PS3: Bash Variables. (line 6093)
  • PS4: Bash Variables. (line 6098)
  • PWD: Bash Variables. (line 6105)
  • RANDOM: Bash Variables. (line 6108)
  • READLINE_ARGUMENT: Bash Variables. (line 6116)
  • READLINE_LINE: Bash Variables. (line 6120)
  • READLINE_MARK: Bash Variables. (line 6124)
  • READLINE_POINT: Bash Variables. (line 6130)
  • REPLY: Bash Variables. (line 6134)
  • revert-all-at-newline: Readline Init File Syntax. (line 8775)
  • search-ignore-case: Readline Init File Syntax. (line 8782)
  • SECONDS: Bash Variables. (line 6138)
  • SHELL: Bash Variables. (line 6148)
  • SHELLOPTS: Bash Variables. (line 6153)
  • SHLVL: Bash Variables. (line 6163)
  • show-all-if-ambiguous: Readline Init File Syntax. (line 8787)
  • show-all-if-unmodified: Readline Init File Syntax. (line 8793)
  • show-mode-in-prompt: Readline Init File Syntax. (line 8802)
  • skip-completed-text: Readline Init File Syntax. (line 8808)
  • SRANDOM: Bash Variables. (line 6168)
  • TEXTDOMAIN: Creating Internationalized Scripts. (line 575)
  • TEXTDOMAINDIR: Creating Internationalized Scripts. (line 575)
  • TIMEFORMAT: Bash Variables. (line 6177)
  • TMOUT: Bash Variables. (line 6216)
  • TMPDIR: Bash Variables. (line 6227)
  • UID: Bash Variables. (line 6231)
  • vi-cmd-mode-string: Readline Init File Syntax. (line 8821)
  • vi-ins-mode-string: Readline Init File Syntax. (line 8832)
  • visible-stats: Readline Init File Syntax. (line 8843)

D.4 函数索引

  • abort (C-g): Miscellaneous Commands. (line 9678)
  • accept-line (Newline or Return): Commands For History. (line 9235)
  • alias-expand-line (): Miscellaneous Commands. (line 9802)
  • backward-char (C-b): Commands For Moving. (line 9185)
  • backward-delete-char (Rubout): Commands For Text. (line 9357)
  • backward-kill-line (C-x Rubout): Commands For Killing. (line 9439)
  • backward-kill-word (M-<DEL>): Commands For Killing. (line 9456)
  • backward-word (M-b): Commands For Moving. (line 9193)
  • beginning-of-history (M-<): Commands For History. (line 9251)
  • beginning-of-line (C-a): Commands For Moving. (line 9173)
  • bracketed-paste-begin (): Commands For Text. (line 9374)
  • call-last-kbd-macro (C-x e): Keyboard Macros. (line 9663)
  • capitalize-word (M-c): Commands For Text. (line 9412)
  • character-search (C-]): Miscellaneous Commands. (line 9709)
  • character-search-backward (M-C-]): Miscellaneous Commands. (line 9713)
  • clear-display (M-C-l): Commands For Moving. (line 9219)
  • clear-screen (C-l): Commands For Moving. (line 9224)
  • complete (<TAB>): Commands For Completion. (line 9530)
  • complete-command (M-!): Commands For Completion. (line 9629)
  • complete-filename (M-/): Commands For Completion. (line 9598)
  • complete-hostname (M-@): Commands For Completion. (line 9621)
  • complete-into-braces (M-{): Commands For Completion. (line 9648)
  • complete-username (M-~): Commands For Completion. (line 9605)
  • complete-variable (M-$): Commands For Completion. (line 9613)
  • copy-backward-word (): Commands For Killing. (line 9490)
  • copy-forward-word (): Commands For Killing. (line 9495)
  • copy-region-as-kill (): Commands For Killing. (line 9486)
  • dabbrev-expand (): Commands For Completion. (line 9643)
  • delete-char (C-d): Commands For Text. (line 9351)
  • delete-char-or-list (): Commands For Completion. (line 9592)
  • delete-horizontal-space (): Commands For Killing. (line 9478)
  • digit-argument (M-0, M-1, ... M--): Numeric Arguments. (line 9510)
  • display-shell-version (C-x C-v): Miscellaneous Commands. (line 9816)
  • do-lowercase-version (M-A, M-B, M-X, ...): Miscellaneous Commands. (line 9682)
  • downcase-word (M-l): Commands For Text. (line 9408)
  • dump-functions (): Miscellaneous Commands. (line 9739)
  • dump-macros (): Miscellaneous Commands. (line 9751)
  • dump-variables (): Miscellaneous Commands. (line 9745)
  • dynamic-complete-history (M-<TAB>): Commands For Completion. (line 9639)
  • edit-and-execute-command (C-x C-e): Miscellaneous Commands. (line 9811)
  • end-kbd-macro (C-x )): Keyboard Macros. (line 9659)
  • end-of-file (usually C-d): Commands For Text. (line 9345)
  • end-of-history (M->): Commands For History. (line 9254)
  • end-of-line (C-e): Commands For Moving. (line 9177)
  • exchange-point-and-mark (C-x C-x): Miscellaneous Commands. (line 9705)
  • execute-named-command (M-x): Miscellaneous Commands. (line 9758)
  • export-completions (): Commands For Completion. (line 9568)
  • fetch-history (): Commands For History. (line 9337)
  • forward-backward-delete-char (): Commands For Text. (line 9362)
  • forward-char (C-f): Commands For Moving. (line 9181)
  • forward-search-history (C-s): Commands For History. (line 9264)
  • forward-word (M-f): Commands For Moving. (line 9189)
  • glob-complete-word (M-g): Miscellaneous Commands. (line 9771)
  • glob-expand-word (C-x *): Miscellaneous Commands. (line 9776)
  • glob-list-expansions (C-x g): Miscellaneous Commands. (line 9782)
  • history-and-alias-expand-line (): Miscellaneous Commands. (line 9805)
  • history-expand-line (M-^): Miscellaneous Commands. (line 9795)
  • history-search-backward (): Commands For History. (line 9282)
  • history-search-forward (): Commands For History. (line 9289)
  • history-substring-search-backward (): Commands For History. (line 9296)
  • history-substring-search-forward (): Commands For History. (line 9302)
  • insert-comment (M-#): Miscellaneous Commands. (line 9727)
  • insert-completions (M-*): Commands For Completion. (line 9548)
  • insert-last-argument (M-. or M-_): Miscellaneous Commands. (line 9808)
  • kill-line (C-k): Commands For Killing. (line 9434)
  • kill-region (): Commands For Killing. (line 9482)
  • kill-whole-line (): Commands For Killing. (line 9447)
  • kill-word (M-d): Commands For Killing. (line 9451)
  • magic-space (): Miscellaneous Commands. (line 9798)
  • menu-complete (): Commands For Completion. (line 9552)
  • menu-complete-backward (): Commands For Completion. (line 9563)
  • next-history (C-n): Commands For History. (line 9247)
  • next-screen-line (): Commands For Moving. (line 9212)
  • non-incremental-forward-search-history (M-n): Commands For History. (line 9276)
  • non-incremental-reverse-search-history (M-p): Commands For History. (line 9270)
  • operate-and-get-next (C-o): Commands For History. (line 9330)
  • overwrite-mode (): Commands For Text. (line 9416)
  • possible-command-completions (C-x !): Commands For Completion. (line 9635)
  • possible-completions (M-?): Commands For Completion. (line 9541)
  • possible-filename-completions (C-x /): Commands For Completion. (line 9601)
  • possible-hostname-completions (C-x @): Commands For Completion. (line 9625)
  • possible-username-completions (C-x ~): Commands For Completion. (line 9609)
  • possible-variable-completions (C-x $): Commands For Completion. (line 9617)
  • prefix-meta (<ESC>): Miscellaneous Commands. (line 9687)
  • previous-history (C-p): Commands For History. (line 9242)
  • previous-screen-line (): Commands For Moving. (line 9205)
  • print-last-kbd-macro (): Keyboard Macros. (line 9667)
  • quoted-insert (C-q or C-v): Commands For Text. (line 9367)
  • re-read-init-file (C-x C-r): Miscellaneous Commands. (line 9674)
  • redraw-current-line (): Commands For Moving. (line 9229)
  • reverse-search-history (C-r): Commands For History. (line 9258)
  • revert-line (M-r): Miscellaneous Commands. (line 9694)
  • self-insert (a, b, A, 1, !, ...): Commands For Text. (line 9371)
  • set-mark (C-@): Miscellaneous Commands. (line 9701)
  • shell-backward-kill-word (): Commands For Killing. (line 9465)
  • shell-backward-word (M-C-b): Commands For Moving. (line 9201)
  • shell-expand-line (M-C-e): Miscellaneous Commands. (line 9787)
  • shell-forward-word (M-C-f): Commands For Moving. (line 9197)
  • shell-kill-word (M-C-d): Commands For Killing. (line 9460)
  • shell-transpose-words (M-C-t): Commands For Text. (line 9397)
  • skip-csi-sequence (): Miscellaneous Commands. (line 9718)
  • spell-correct-word (C-x s): Miscellaneous Commands. (line 9765)
  • start-kbd-macro (C-x (): Keyboard Macros. (line 9656)
  • tilde-expand (M-&): Miscellaneous Commands. (line 9698)
  • transpose-chars (C-t): Commands For Text. (line 9386)
  • transpose-words (M-t): Commands For Text. (line 9392)
  • undo (C-_ or C-x C-u): Miscellaneous Commands. (line 9691)
  • universal-argument (): Numeric Arguments. (line 9514)
  • unix-filename-rubout (): Commands For Killing. (line 9473)
  • unix-line-discard (C-u): Commands For Killing. (line 9444)
  • unix-word-rubout (C-w): Commands For Killing. (line 9469)
  • upcase-word (M-u): Commands For Text. (line 9404)
  • yank (C-y): Commands For Killing. (line 9500)
  • yank-last-arg (M-. or M-_): Commands For History. (line 9318)
  • yank-nth-arg (M-C-y): Commands For History. (line 9308)
  • yank-pop (M-y): Commands For Killing. (line 9503)

D.5 概念索引

  • alias expansion: Aliases. (line 6881)
  • arithmetic evaluation: Shell Arithmetic. (line 6781)
  • arithmetic expansion: Arithmetic Expansion. (line 2333)
  • arithmetic operators: Shell Arithmetic. (line 6793)
  • arithmetic, shell: Shell Arithmetic. (line 6781)
  • arrays: Arrays. (line 6939)
  • background: Job Control Basics. (line 7892)
  • Bash configuration: Basic Installation. (line 10843)
  • Bash installation: Basic Installation. (line 10843)
  • binary arithmetic operators: Shell Arithmetic. (line 6793)
  • bitwise arithmetic operators: Shell Arithmetic. (line 6793)
  • Bourne shell: Basic Shell Features. (line 336)
  • brace expansion: Brace Expansion. (line 1632)
  • builtin: Definitions. (line 257)
  • command editing: Readline Bare Essentials. (line 8244)
  • command execution: Command Search and Execution. (line 2893)
  • command expansion: Simple Command Expansion. (line 2851)
  • command history: Bash History Facilities. (line 10384)
  • command search: Command Search and Execution. (line 2893)
  • command substitution: Command Substitution. (line 2257)
  • command timing: Pipelines. (line 673)
  • commands, compound: Compound Commands. (line 774)
  • commands, conditional: Conditional Constructs. (line 851)
  • commands, grouping: Command Grouping. (line 1158)
  • commands, lists: Lists. (line 729)
  • commands, looping: Looping Constructs. (line 791)
  • commands, pipelines: Pipelines. (line 670)
  • commands, shell: Shell Commands. (line 628)
  • commands, simple: Simple Commands. (line 657)
  • comments, shell: Comments. (line 614)
  • Compatibility Level: Shell Compatibility Mode. (line 7722)
  • Compatibility Mode: Shell Compatibility Mode. (line 7722)
  • completion builtins: Programmable Completion Builtins. (line 9990)
  • conditional arithmetic operator: Shell Arithmetic. (line 6793)
  • configuration: Basic Installation. (line 10843)
  • control operator: Definitions. (line 261)
  • coprocess: Coprocesses. (line 1192)
  • directory stack: The Directory Stack. (line 7084)
  • dollar-single quote quoting: ANSI-C Quoting. (line 457)
  • editing command lines: Readline Bare Essentials. (line 8244)
  • environment: Environment. (line 3015)
  • evaluation, arithmetic: Shell Arithmetic. (line 6781)
  • event designators: Event Designators. (line 10671)
  • execution environment: Command Execution Environment. (line 2937)
  • exit status: Definitions. (line 266)
  • exit status <1>: Exit Status. (line 3050)
  • expansion: Shell Expansions. (line 1596)
  • expansion, arithmetic: Arithmetic Expansion. (line 2333)
  • expansion, brace: Brace Expansion. (line 1632)
  • expansion, filename: Filename Expansion. (line 2428)
  • expansion, parameter: Shell Parameter Expansion. (line 1761)
  • expansion, pathname: Filename Expansion. (line 2428)
  • expansion, tilde: Tilde Expansion. (line 1692)
  • expressions, arithmetic: Shell Arithmetic. (line 6781)
  • expressions, conditional: Bash Conditional Expressions. (line 6625)
  • field: Definitions. (line 270)
  • filename: Definitions. (line 275)
  • filename expansion: Filename Expansion. (line 2428)
  • foreground: Job Control Basics. (line 7892)
  • functions, shell: Shell Functions. (line 1269)
  • history builtins: Bash History Builtins. (line 10446)
  • history events: Event Designators. (line 10675)
  • history expansion: History Interaction. (line 10584)
  • history list: Bash History Facilities. (line 10384)
  • History, how to use: A Programmable Completion Example. (line 10373)
  • identifier: Definitions. (line 291)
  • initialization file, readline: Readline Init File. (line 8412)
  • installation: Basic Installation. (line 10843)
  • interaction, readline: Readline Interaction. (line 8230)
  • interactive shell: Invoking Bash. (line 6373)
  • interactive shell <1>: Interactive Shells. (line 6505)
  • internationalization: Locale Translation. (line 509)
  • internationalized scripts: Creating Internationalized Scripts. (line 527)
  • job: Definitions. (line 278)
  • job control: Definitions. (line 282)
  • job control <1>: Job Control Basics. (line 7892)
  • kill ring: Readline Killing Commands. (line 8319)
  • killing text: Readline Killing Commands. (line 8307)
  • localization: Locale Translation. (line 509)
  • login shell: Invoking Bash. (line 6370)
  • matching, pattern: Pattern Matching. (line 2482)
  • metacharacter: Definitions. (line 286)
  • name: Definitions. (line 291)
  • native languages: Locale Translation. (line 509)
  • notation, readline: Readline Bare Essentials. (line 8244)
  • operator, shell: Definitions. (line 297)
  • parameter expansion: Shell Parameter Expansion. (line 1761)
  • parameters: Shell Parameters. (line 1431)
  • parameters, positional: Positional Parameters. (line 1510)
  • parameters, special: Special Parameters. (line 1528)
  • pathname expansion: Filename Expansion. (line 2428)
  • pattern matching: Pattern Matching. (line 2482)
  • pipeline: Pipelines. (line 670)
  • POSIX: Definitions. (line 245)
  • POSIX description: Bash POSIX Mode. (line 7337)
  • POSIX Mode: Bash POSIX Mode. (line 7376)
  • process group: Definitions. (line 302)
  • process group ID: Definitions. (line 306)
  • process substitution: Process Substitution. (line 2356)
  • programmable completion: Programmable Completion. (line 9840)
  • prompting: Controlling the Prompt. (line 7201)
  • quoting: Quoting. (line 398)
  • quoting, ANSI: ANSI-C Quoting. (line 457)
  • Readline, how to use: Job Control Variables. (line 8165)
  • redirection: Redirections. (line 2602)
  • reserved word: Definitions. (line 310)
  • reserved words: Reserved Words. (line 639)
  • restricted shell: The Restricted Shell. (line 7280)
  • return status: Definitions. (line 315)
  • shell arithmetic: Shell Arithmetic. (line 6781)
  • shell function: Shell Functions. (line 1269)
  • shell script: Shell Scripts. (line 3179)
  • shell variable: Shell Parameters. (line 1431)
  • shell, interactive: Interactive Shells. (line 6505)
  • signal: Definitions. (line 318)
  • signal handling: Signals. (line 3093)
  • special builtin: Definitions. (line 322)
  • special builtin <1>: Special Builtins. (line 5340)
  • startup files: Bash Startup Files. (line 6393)
  • string translations: Creating Internationalized Scripts. (line 527)
  • suspending jobs: Job Control Basics. (line 7892)
  • tilde expansion: Tilde Expansion. (line 1692)
  • token: Definitions. (line 326)
  • translation, native languages: Locale Translation. (line 509)
  • unary arithmetic operators: Shell Arithmetic. (line 6793)
  • variable, shell: Shell Parameters. (line 1431)
  • variables, readline: Readline Init File Syntax. (line 8462)
  • word: Definitions. (line 330)
  • word splitting: Word Splitting. (line 2381)
  • yanking text: Readline Killing Commands. (line 8307)

posted @ 2026-08-07 04:41  立体风  阅读(11)  评论(0)    收藏  举报