ubutu下source命令问题

最近一段时间在使用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 -> dash

修改下:
root@localhost:~# dpkg-reconfigure dash

之后选择否,此时再看系统中使用的shell环境就改成bash
root@localhost:~# ls -l $(which sh)
lrwxrwxrwx 1 root root 4 9月  9 22:09 /bin/sh -> bash

在此时就可以使用source

原文地址:https://www.cnblogs.com/brandon-zhang/p/7867602.html