# Difference between sh and bash

### What is sh

sh (or the Shell Command Language) is a programming language described by thePOSIX standard. It has many implementations (ksh88, dash, …). bash can also be considered an implementation of sh (see below).

sh(也被称为Shell Command Language) 是一种基于POSIX标准的编程语言. 它有很多的实现(ksh88, dash,…). bash也被认为是sh的一种实现.

Because sh is a specification, not an implementation, /bin/sh is a symlink (or a hard link) to an actual implementation on most POSIX systems.

### What is bash

bash started as an sh-compatible implementation (although it predates the POSIX standard by a few years), but as time passed it has acquired many extensions. Many of these extensions may change the behavior of valid POSIX shell scripts, so by itself bash is not a valid POSIX shell. Rather, it is a dialect of the POSIX shell language.

bash 开始作为一种适配sh的实现(尽管它反而早于POSIX标准几年问世), 但是随着时间的推移, bash获得了更多的扩展. 这些扩展中很多都改变了标准POSIX脚本的行为, 所以bash本身并不是一个标准的符合POSIX标准的shell. 更形象一点来说, bashPOSIX脚本语言的一种方言.

bash supports a --posix switch, which makes it more POSIX-compliant. It also tries to mimic POSIX if invoked as sh.

bash 支持 --posix 切换, 能够更适配POSIX.