最近一段时间在使用Bash on Ubuntu on Windows作shell脚本调试时发如今脚本中使用source时会报错,上网查了下才了解到原来是在Ubuntu中使用的并非bash,而是使用 优化过的dash,而在dash中是没有source,而在bash中才有source,这就有点麻烦了,平时在写脚本时有时会调用系统的 function和一些自定义的function,没有source确实有点不太方便,而在此时能够在使用dpkg-reconfigure来修改配置 dash,在平时能够用如下方法来验证看下本身的系统中使用的shell环境:
root@localhost:~# ls -l $(which sh)
lrwxrwxrwx 1 root root 4 9月 9 22:09 /bin/sh -> dashlinux
修改下:
root@localhost:~# dpkg-reconfigure dashshell
以后选择否,此时再看系统中使用的shell环境就改为bash
root@localhost:~# ls -l $(which sh)
lrwxrwxrwx 1 root root 4 9月 9 22:09 /bin/sh -> bashbash
在此时就能够使用source优化