沙盒
At its base, a shell is simply a macro processor that executes commands. The term macro processor means functionality where text and symbols are expanded to create larger expressions.
于其基础,shell是一个简单的用于执行指令的宏处理器。宏处理器这个术语意味着这样的功能,那里一些文本和符号可被扩展成为更大的表达式。
A Unix shell is both a command interpreter and a programming language. As a command interpreter, the shell provides the user interface to the rich set of GNU utilities. The programming language features allow these utilities to be combined. Files containing commands can be created, and become commands themselves. These new commands have the same status as system commands in directories such as /bin, allowing users or groups to establish custom environments to automate their common tasks.
Unix shell既是一个指令解释器也是一种编程语言。作为指令解释器,shell针对丰富的GUN工具提供了用户接口。而它的编程语言特性又允许这些工具可被组合起来。包含指令的文件可以被创建,而它们又成为指令的一部分。这些新指令与在其他目录中的系统指令有着相同的地位例如/bin,并允许用户或组去建立客户环境或自动化他们的公共任务。
Shells may be used interactively or non-interactively. In interactive mode, they accept input typed from the keyboard. When executing non-interactively, shells execute commands read from a file.
Shells的使用可以是交互或非交互的。在交互模式下,它们接受键盘输入。在非交互执行时, shells执行可从文件读取。
A shell allows execution of GNU commands, both synchronously and asynchronously. The shell waits for synchronous commands to complete before accepting more input; asynchronous commands continue to execute in parallel with the shell while it reads and executes additional commands. The redirection constructs permit fine-grained control of the input and output of those commands. Moreover, the shell allows control over the contents of commands’ environments.
一个shell允许一同步和异步两种方式执行GNU指令。对于同步指令shell等待以完成更多的输入;对于异步指令shell执行读或其它指令是并发执行的。重定向构造允许一更细的粒度控制指令的输入和输出。而且,shell允许支配指令环境的内容。
Shells also provide a small set of built-in commands (builtins) implementing functionality impossible or inconvenient to obtain via separate utilities. For example, cd, break, continue, and exec cannot be implemented outside of the shell because they directly manipulate the shell itself. The history, getopts, kill, or pwd builtins, among others, could be implemented in separate utilities, but they are more convenient to use as builtin commands. All of the shell builtins are described in subsequent sections.
Shells也针对那些不可能或不方便获得的第三方工具提供了少量内置指令(嵌入部件)的功能实现。例如:cd,break,continue以及exec等无法再shell外部实现因为它们直接操纵shell自己。历史上getopts、kill或pwd等嵌入组件,及其他可以被分别实现为不同工具,但是作为内置的指令,它们更方便一些。所有这些shell嵌入部件后面的章节还将介绍。
While executing commands is essential, most of the power (and complexity) of shells is due to their embedded programming languages. Like any high-level language, the shell provides variables, flow control constructs, quoting, and functions.
当必须执行指令时,shells的强大或复杂之处应归结于它们的嵌入式编程语言。如同其他任何高级语言,shell提供变量、流程控制结构、引用已经函数等功能。
Shells offer features geared specifically for interactive use rather than to augment the programming language. These interactive features include job control, command line editing, command history and aliases. Each of these features is described in this manual.
Shells提供的特性特别适合交互使用而非增加编程语言。这些交互特性包括作业控制、命令行编辑、命令历史记录和别名。所有这些特性都将在本手册中叙述。