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)

Enable 'alias' and 'source' in .sh non-interactive env_第1张图片
Enable 'alias' and 'source' in .sh non-interactive env_第2张图片

你可能感兴趣的:(Enable 'alias' and 'source' in .sh non-interactive env)