Enable 'alias' and 'source' in .sh non-interactive env

1. Enable 'alias' to be executable in shell script: 1).exe 'shopt -s expand_aliases' in .sh, and; 2). using 'source shell_name.sh' to execute shell script;  or else, if using './shell_name.sh', the 'alias' command in script will not be executed, cause shell will not invoke another process for it while will for 'date' and others.

2. Enable 'source' to executable in shell scripts: #!/bin/sh  ===change to===> #!/bin/bash

           ### comment 'exit 0' in the last line of script, or else the windows will be disappeared(EXITED).

3. sh script.sh === ./script.sh   (#!/bin/sh) ;  source script.sh === . script.sh  (#!/bin/bash)

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容