ubuntu下的sh是到dash(the Debian Almquist Shell)的链接
原因参考这里
https://wiki.ubuntu.com/DashAsBinSh

502 ~>ls /bin/bash -l
-rwxr-xr-x 1 root root 729040 2009-03-02 22:22 /bin/bash
503 ~>ls /bin/sh -l
lrwxrwxrwx 1 root root 4 2008-11-05 02:05 /bin/sh -> dash
504 ~>ls /bin/dash -l
-rwxr-xr-x 1 root root 87924 2008-11-05 15:51 /bin/dash
505 ~>echo $SHELL
/bin/bash

以前以为sh就是到/bin/bash的链接,昨天就遇到了问题

The Debian policy manual has long mandated that “shell scripts specifying ‘/bin/sh’ as interpreter must only use POSIX features”; in fact, this requirement has been in place since well before the inception of the Ubuntu project. Furthermore, any shell scripts that expected to be portable to other Unix systems, such as the BSDs or Solaris, already honoured this requirement. Thus, we felt that the compatibility impact of this change would be minimal.

所以如果你的脚本中声明了这样
#! /bin/sh
那么你就应该只用POSIX标准中的语法,如果你需要用到某个shell特有的语法,那么需要明确指定shell
#! /bin/bash