小编par*_*y72的帖子

当带有扩展通配选项的“cp”语句移动到“if”块时出现语法错误

在 Bash 中进行复制时遇到一些问题。这工作正常:

# Enable extended globbing and include filenames beginning with a '.'
shopt -s extglob dotglob
# Copy git repo to expected place
cp -r !($YOCTO_DIR) $POKY_DIR/$GIT_REPO_NAME/
Run Code Online (Sandbox Code Playgroud)

但当我if对此发表声明时:

if [ -z "$FROM_JENKINS" ]; then
    # FROM_JENKINS is blank, this is a local build

    # Enable extended globbing and include filenames beginning with a '.'
    shopt -s extglob dotglob
    # Copy git repo to expected place
    cp -r !($YOCTO_DIR) $POKY_DIR/$GIT_REPO_NAME/
fi
Run Code Online (Sandbox Code Playgroud)

我得到:

./build.sh: line 80: syntax error …
Run Code Online (Sandbox Code Playgroud)

bash wildcards

11
推荐指数
1
解决办法
1257
查看次数

标签 统计

bash ×1

wildcards ×1