This line in a bash file has been working for six months:
SCRATCH_FOLDER_NAME="${SCRATCH_FOLDER_NAME:scratch--folder}"
and today it decided to be no more, with this error:
SCRATCH_FOLDER_NAME: scratch--folder: syntax error in expression (error token is "folder")
What does it mean?
For reference, here is the complete script:
#!/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
"${SCRATCH_FOLDER_NAME:scratch--folder}" is not a correct parameter expansion. Consider the following, where comma is the delimiter:
# 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##*,}
As for how it worked I am not sure. Here is a good reference for the different types of parameter expansions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With