mirror of
https://github.com/kossakovsky/n8n-install.git
synced 2026-03-07 22:33:11 +00:00
Enhance unquoting logic in secrets generation script
- Updated the unquoting mechanism in 03_generate_secrets.sh to repeatedly remove surrounding quotes from variable values, improving the handling of quoted strings and ensuring accurate environment variable assignment.
This commit is contained in:
@@ -54,10 +54,20 @@ if [ -f "$OUTPUT_FILE" ]; then
|
||||
if [[ -n "$line" && ! "$line" =~ ^\\s*# && "$line" == *"="* ]]; then
|
||||
varName=$(echo "$line" | cut -d'=' -f1 | xargs)
|
||||
varValue=$(echo "$line" | cut -d'=' -f2-)
|
||||
# Simple unquote for "value" or 'value'
|
||||
if [[ "$varValue" =~ ^\\"(.*)\\"$ || "$varValue" =~ ^\\'(.*)\\'$ ]]; then
|
||||
varValue="${BASH_REMATCH[1]}"
|
||||
fi
|
||||
# Repeatedly unquote "value" or 'value' to get the bare value
|
||||
_tempVal="$varValue"
|
||||
while true; do
|
||||
if [[ "$_tempVal" =~ ^\"(.*)\"$ ]]; then # Check double quotes
|
||||
_tempVal="${BASH_REMATCH[1]}"
|
||||
continue
|
||||
fi
|
||||
if [[ "$_tempVal" =~ ^\'(.*)\'$ ]]; then # Check single quotes
|
||||
_tempVal="${BASH_REMATCH[1]}"
|
||||
continue
|
||||
fi
|
||||
break # No more surrounding quotes of these types
|
||||
done
|
||||
varValue="$_tempVal"
|
||||
existing_env_vars["$varName"]="$varValue"
|
||||
fi
|
||||
done < "$OUTPUT_FILE"
|
||||
|
||||
Reference in New Issue
Block a user