From f13dd6834a9f9664d3d72b2beb40cc5c54580505 Mon Sep 17 00:00:00 2001 From: wangyueliang Date: Wed, 5 Jun 2024 17:34:15 +0800 Subject: [PATCH] Fix the issue of using absolute path init and report directory is not empty --- src/cmd-init | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cmd-init b/src/cmd-init index f53bdfd9..53402aef 100755 --- a/src/cmd-init +++ b/src/cmd-init @@ -82,15 +82,15 @@ if [ $# = 0 ]; then exit 1 fi +source=$1; shift +subdir=${1:-} + # If the current working dir is not empty then error out # unless force provided -if [ "$FORCE" != "1" ] && [ -n "$(ls ./)" ]; then +if [[ ${source} != /* ]] && [ "$FORCE" != "1" ] && [ -n "$(ls ./)" ]; then fatal "init: current directory is not empty, override with --force" fi -source=$1; shift -subdir=${1:-} - preflight if has_privileges; then -- Gitee