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"
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"
cd / ./$CCI_SRC/sparrow/3-code/dev-env
if use relative path,will error
. "$path" no such file
Thanks, Shenwei
2.23.0
source /etc/os-release
--
cd / ./$CCI_SRC/sparrow/3-code/dev-env
i use set -x to debug as follow: path=$(dirname ${BASH_SOURCE[0]})/os/${ID} [ -x "$path" ] && . "$path" => ++ dirname 3-code/dev-env + path=3-code/os/openEuler + '[' -x 3-code/os/openEuler ']'
if use relative path,will error
have no error.
Thanks, Yinsi
. "$path" no such file
Thanks, Shenwei
2.23.0
On Thu, Nov 12, 2020 at 08:24:20PM +0800, Liu Yinsi wrote:
source /etc/os-release
--
cd / ./$CCI_SRC/sparrow/3-code/dev-env
i use set -x to debug as follow: path=$(dirname ${BASH_SOURCE[0]})/os/${ID} [ -x "$path" ] && . "$path" => ++ dirname 3-code/dev-env + path=3-code/os/openEuler + '[' -x 3-code/os/openEuler ']'
if use relative path,will error
have no error.
ok, misread
Thanks, Shenwei
Thanks, Yinsi
. "$path" no such file
Thanks, Shenwei
2.23.0
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"
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
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