On Thu, Nov 12, 2020 at 06:30:22PM +0800, Yu Chuan wrote:
On Thu, Nov 12, 2020 at 02:55:08PM +0800, Liu Yinsi wrote:
when execute 3-code/dev-env, error message as follows:
./dev-env: line 45: ./os/openEuler: No such file or directory
Signed-off-by: Liu Yinsi liuyinsi@163.com
sparrow/3-code/dev-env | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/sparrow/3-code/dev-env b/sparrow/3-code/dev-env index 77027d9..98da280 100755 --- a/sparrow/3-code/dev-env +++ b/sparrow/3-code/dev-env @@ -42,4 +42,5 @@ EOF
source /etc/os-release
-. $(dirname ${BASH_SOURCE[0]})/os/${ID} +path=$(dirname ${BASH_SOURCE[0]})/os/${ID} +[ -x "$path" ] && . "$path"
you'd better modify here as the follow: [ -x "$path" ] || exit 0 . "$path"
good Thanks, Yinsi
Here is the reason:
looks `[ -x .. ] && ..` is the last line of this file.
so the return code of last line of a script will be the execute code of this script.
return code of `[ -x .. ] && ..` will be 1 if $path is not exist or not have execute permission. yuchuan@crystal ~% [ -x 123 ] && echo 123; echo $? 1
so if you have set -e in script, this will cause the exit of program.
Thanks Yu Chuan
-- 2.23.0