[PATCH compass-ci] use cd "$xxx" for safety reason

Signed-off-by: Liu Yinsi <liuyinsi@163.com> --- container/docker2rootfs/common | 4 ++-- sparrow/4-docker/buildall | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/container/docker2rootfs/common b/container/docker2rootfs/common index e908079..c26bbc8 100755 --- a/container/docker2rootfs/common +++ b/container/docker2rootfs/common @@ -96,7 +96,7 @@ load_docker_img() cp_rootfs() { docker cp -a rootfs-docker:/tmp/$1 /tmp/ - cd $2 + cd "$2" zcat /tmp/$1 |cpio -idmv } @@ -148,7 +148,7 @@ create_links_vmlinuz_initrd() create_get_initrd echo "Creating links to initrd.lkp and vmlinuz..." - cd $ROOTFS_DIR + cd "$ROOTFS_DIR" ln -fs $ROOTFS_INITRD_LKP initrd.lkp cd $ROOTFS_DIR/boot ln -fs $ROOTFS_VMLINUZ vmlinuz diff --git a/sparrow/4-docker/buildall b/sparrow/4-docker/buildall index ca4406b..f24226c 100755 --- a/sparrow/4-docker/buildall +++ b/sparrow/4-docker/buildall @@ -30,7 +30,7 @@ do_one() [ -n "$LKP_SRC" ] && log_info "start build $container." mkdir $tmpdir/$container_name 2>/dev/null && ( - cd $container + cd "$container" [ "$container_name" == 'ssh-r' ] && exit docker images | grep -wq "$container_name" if [ "$?" == 0 ] && [ "$action" != "reboot" ]; then -- 2.23.0

On Wed, Jan 13, 2021 at 03:16:23PM +0800, Liu Yinsi wrote:
Signed-off-by: Liu Yinsi <liuyinsi@163.com> --- container/docker2rootfs/common | 4 ++-- sparrow/4-docker/buildall | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/container/docker2rootfs/common b/container/docker2rootfs/common index e908079..c26bbc8 100755 --- a/container/docker2rootfs/common +++ b/container/docker2rootfs/common @@ -96,7 +96,7 @@ load_docker_img() cp_rootfs() { docker cp -a rootfs-docker:/tmp/$1 /tmp/ - cd $2 + cd "$2" zcat /tmp/$1 |cpio -idmv }
@@ -148,7 +148,7 @@ create_links_vmlinuz_initrd() create_get_initrd
echo "Creating links to initrd.lkp and vmlinuz..." - cd $ROOTFS_DIR + cd "$ROOTFS_DIR" ln -fs $ROOTFS_INITRD_LKP initrd.lkp cd $ROOTFS_DIR/boot
How about add "" here? cd "$ROOTFS_DIR/boot" Thanks, Chenglong
ln -fs $ROOTFS_VMLINUZ vmlinuz diff --git a/sparrow/4-docker/buildall b/sparrow/4-docker/buildall index ca4406b..f24226c 100755 --- a/sparrow/4-docker/buildall +++ b/sparrow/4-docker/buildall @@ -30,7 +30,7 @@ do_one() [ -n "$LKP_SRC" ] && log_info "start build $container." mkdir $tmpdir/$container_name 2>/dev/null && ( - cd $container + cd "$container" [ "$container_name" == 'ssh-r' ] && exit docker images | grep -wq "$container_name" if [ "$?" == 0 ] && [ "$action" != "reboot" ]; then -- 2.23.0

- cd $ROOTFS_DIR + cd "$ROOTFS_DIR" ln -fs $ROOTFS_INITRD_LKP initrd.lkp cd $ROOTFS_DIR/boot
How about add "" here?
lys@crystal /c/compass-ci% ab= lys@crystal /c/compass-ci% cd "$ab" file not exist; cd into parent dir instead lys@crystal /c/compass-ci% ab= lys@crystal /c/compass-ci% cd "$ab/c/compass-ci" lys@crystal /c/compass-ci% if cd $xxx/xxx, use "" not work. Thanks, Yinsi
cd "$ROOTFS_DIR/boot"
Thanks, Chenglong
ln -fs $ROOTFS_VMLINUZ vmlinuz diff --git a/sparrow/4-docker/buildall b/sparrow/4-docker/buildall index ca4406b..f24226c 100755 --- a/sparrow/4-docker/buildall +++ b/sparrow/4-docker/buildall @@ -30,7 +30,7 @@ do_one() [ -n "$LKP_SRC" ] && log_info "start build $container." mkdir $tmpdir/$container_name 2>/dev/null && ( - cd $container + cd "$container" [ "$container_name" == 'ssh-r' ] && exit docker images | grep -wq "$container_name" if [ "$?" == 0 ] && [ "$action" != "reboot" ]; then -- 2.23.0

On Wed, Jan 13, 2021 at 03:26:13PM +0800, Liu Yinsi wrote:
- cd $ROOTFS_DIR + cd "$ROOTFS_DIR" ln -fs $ROOTFS_INITRD_LKP initrd.lkp cd $ROOTFS_DIR/boot
How about add "" here?
lys@crystal /c/compass-ci% ab= lys@crystal /c/compass-ci% cd "$ab" file not exist; cd into parent dir instead lys@crystal /c/compass-ci% ab= lys@crystal /c/compass-ci% cd "$ab/c/compass-ci" lys@crystal /c/compass-ci%
if cd $xxx/xxx, use "" not work.
wcl@z9 ~% ab=compass-ci wcl@z9 ~% cd $ab wcl@z9 ~/compass-ci% wcl@z9 ~% cd "$ab/doc" wcl@z9 ~/compass-ci/doc% It's also can work. Thanks, Chenglong
Thanks, Yinsi
cd "$ROOTFS_DIR/boot"
Thanks, Chenglong
ln -fs $ROOTFS_VMLINUZ vmlinuz diff --git a/sparrow/4-docker/buildall b/sparrow/4-docker/buildall index ca4406b..f24226c 100755 --- a/sparrow/4-docker/buildall +++ b/sparrow/4-docker/buildall @@ -30,7 +30,7 @@ do_one() [ -n "$LKP_SRC" ] && log_info "start build $container." mkdir $tmpdir/$container_name 2>/dev/null && ( - cd $container + cd "$container" [ "$container_name" == 'ssh-r' ] && exit docker images | grep -wq "$container_name" if [ "$?" == 0 ] && [ "$action" != "reboot" ]; then -- 2.23.0

How about add "" here?
lys@crystal /c/compass-ci% ab= lys@crystal /c/compass-ci% cd "$ab" file not exist; cd into parent dir instead lys@crystal /c/compass-ci% ab= lys@crystal /c/compass-ci% cd "$ab/c/compass-ci" lys@crystal /c/compass-ci%
if cd $xxx/xxx, use "" not work.
wcl@z9 ~% ab=compass-ci wcl@z9 ~% cd $ab wcl@z9 ~/compass-ci% wcl@z9 ~% cd "$ab/doc" wcl@z9 ~/compass-ci/doc%
It's also can work.
ab为空的时候呢,cd的时候加了双引号也不会报错呀,跟不加没有区别 Thanks, Yinsi
Thanks, Chenglong
Thanks, Yinsi
cd "$ROOTFS_DIR/boot"
Thanks, Chenglong
ln -fs $ROOTFS_VMLINUZ vmlinuz diff --git a/sparrow/4-docker/buildall b/sparrow/4-docker/buildall index ca4406b..f24226c 100755 --- a/sparrow/4-docker/buildall +++ b/sparrow/4-docker/buildall @@ -30,7 +30,7 @@ do_one() [ -n "$LKP_SRC" ] && log_info "start build $container." mkdir $tmpdir/$container_name 2>/dev/null && ( - cd $container + cd "$container" [ "$container_name" == 'ssh-r' ] && exit docker images | grep -wq "$container_name" if [ "$?" == 0 ] && [ "$action" != "reboot" ]; then -- 2.23.0
participants (2)
-
Liu Yinsi
-
Wang Chenglong