个人工具

Bash Reference Manual/zh

来自Ubuntu中文

Jinzd讨论 | 贡献2016年6月24日 (五) 16:36的版本 What is a shell?

跳转至: 导航, 搜索

本文引自https://www.gnu.org/software/bash/manual/bash.html#Readline-Bare-Essentials.

Bash特性

This text is a brief description of the features that are present in the Bash shell (version 4.3, 2 February 2014). The Bash home page is http://www.gnu.org/software/bash/.

这部分文字是当前Bash shell(版本4.3, 2014年2月)特性的一个简要描述。Bash的主页是http://www.gnu.org/software/bash/.

This is Edition 4.3, last updated 2 February 2014, of The GNU Bash Reference Manual, for Bash, Version 4.3.

此4.3版本更新于2014年2月,它的GNU Bash参考手册也是针对此4.3版本。

Bash contains features that appear in other popular shells, and some features that only appear in Bash. Some of the shells that Bash has borrowed concepts from are the Bourne Shell (sh), the Korn Shell (ksh), and the C-shell (csh and its successor, tcsh). The following menu breaks the features up into categories, noting which features were inspired by other shells and which are specific to Bash.

Bash所涵盖的一些特性也出现在其他流行的shells中。Bash的有些概念来自于其他的一些shells例如Bourne Shell(sh)、Korn Shell (ksh)以及C-shell(csh及其后继者,如tcsh)。以下菜单把这些特性进行了分类,并且不刻意哪些特性来自于其他的shells或者哪些特性来自于某个特定的Bash。

This manual is meant as a brief introduction to features found in Bash. The Bash manual page should be used as the definitive reference on shell behavior.

本手册意图扼要介绍Bash中的特性。本Bash手册应作为shell的引用参考来使用。

Introduction: An introduction to the shell.

shell介绍。

Definitions: Some definitions used in the rest of this manual.

手册中使用的一些定义。

Basic Shell Features: The shell "building blocks".

shell”构造块”

Shell Builtin Commands: Commands that are a part of the shell.

shell指令。

Shell Variables: Variables used or set by Bash.

Bash中使用的变量。

Bash Features: Features found only in Bash.

Bash独有特性。

Job Control: What job control is and how Bash allows you to use it.

什么是作业控制已经Bash中如何允许使用作业控制。

Command Line Editing: Chapter describing the command line editing features.

命令行编辑功能的章节描述。

Using History Interactively: Command History Expansion

指令历史增强

Installing Bash: How to build and install Bash on your system.

如果在你的系统中建造和安装Bash。

Reporting Bugs: How to report bugs in Bash.

如何报告Bash中的Bug。

Major Differences From The Bourne Shell: A terse list of the differences between Bash and historical versions of /bin/sh.

一个简洁列(/bin/sh)表以介绍Bash历史版本的不同。

GNU Free Documentation License: Copying and sharing this documentation.

拷贝及共享此文档。

Indexes: Various indexes for this manual.

此手册的个中索引。

Introduction

What is Bash?

Bash is the shell, or command language interpreter, for the GNU operating system. The name is an acronym for the 'Bourne-Again SHell', a pun on Stephen Bourne, the author of the direct ancestor of the current Unix shell sh, which appeared in the Seventh Edition Bell Labs Research version of Unix.

Bash是shell,或者,对于GUN操作系统而言它也叫做指令语言解释器。这个名字源于"Bourne-Again SHell"的首字母缩写,Stephen Bourne的双关语,其直接始祖源自当前Unix shell sh,它始现于贝尔实验室Unix的第七个版本。

Bash is largely compatible with sh and incorporates useful features from the Korn shell ksh and the C shell csh. It is intended to be a conformant implementation of the IEEE POSIX Shell and Tools portion of the IEEE POSIX specification (IEEE Standard 1003.1). It offers functional improvements over sh for both interactive and programming use.

Bash在很大程度上与sh是兼容的,并且它也从Korn shell ksh以及C shell csh纳入了一些有用的功能。它的目的是成为IEEE POSIX Shell的一致实现,以及IEEE POSIX规范(IEEE Standard 1003.1)的工具部分。他提供了sh针对交互及编程方面的功能改善。

While the GNU operating system provides other shells, including a version of csh, Bash is the default shell. Like other GNU software, Bash is quite portable. It currently runs on nearly every version of Unix and a few other operating systems - independently-supported ports exist for MS-DOS, OS/2, and Windows platforms.

在GNU操作系统提供其他shells时,包括csh的一个版本,Bash是缺省的shell。如同其他GNU软件,Bash是非常便携的。它几乎允许于每一个版本的Unix以及其他一些操作系统 - 基于端口提供独立支持如MS-DOS,OS/2以及Windows平台。

What is a shell?

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提供的特性特别适合交互使用而非增加编程语言。这些交互特性包括作业控制、命令行编辑、命令历史记录和别名。所有这些特性都将在本手册中叙述。