bash文件中的这一行已经工作了六个月:
SCRATCH_FOLDER_NAME="${SCRATCH_FOLDER_NAME:scratch--folder}"
今天它决定不再有这个错误:
SCRATCH_FOLDER_NAME: scratch--folder: syntax error in expression (error token is "folder")
这是什么意思?
供参考,这是完整的脚本:
#!/bin/bash
SHIMMERCAT_SCRATCH_FOLDER_NAME="${SHIMMERCAT_SCRATCH_FOLDER_NAME:shimmercat-scratch--folder}"
REDIS_UNIX_SOCKET="/unpriv/$SHIMMERCAT_SCRATCH_FOLDER_NAME/redis.sock"
if [[ -z ${DONT_RUN_REDIS+x} ]]; then
chown shimmercat:shimmercat $SHIMMERCAT_SCRATCH_FOLDER_NAME
...
fi
答案 0 :(得分:3)
"${SCRATCH_FOLDER_NAME:scratch--folder}"
不是正确的参数扩展。请考虑以下内容,其中逗号是分隔符:
# Get string before first matching delimeter
${var%%,*}
# Get string before last matching delimeter
${var%,*}
# Get string after first matching delimeter
${var#*,}
# Get string after last matching delimeter
${var##*,}
至于它是如何工作的,我不确定。 Here是不同类型参数扩展的良好参考。