Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Commit

Permalink
Add escaping to ampersand
Browse files Browse the repository at this point in the history
To resolve problem with multi-command Drone scripts caused by a change in Bash 5.1:
> x. New shell option: patsub_replacement. When enabled, a `&' in the replacement
>  string of the pattern substitution expansion is replaced by the portion of
>  the string that matched the pattern. Backslash will escape the `&' and
>  insert a literal `&'.

https://tiswww.case.edu/php/chet/bash/NEWS
  • Loading branch information
danielt998 authored Feb 5, 2024
1 parent 1118721 commit 59b7f13
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion command.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if [[ "${PLUGIN_CMD:-}" == "" ]]; then
fi
# If multiple cmd lines have been provided, chain them into something which we can execute with sh
# Note that Drone provides these lines in comma separated form without escaping, which means commas in commands are known to break
export PLUGIN_CMD=${PLUGIN_CMD//,/ && }
export PLUGIN_CMD=${PLUGIN_CMD//,/ \&\& }

# Wrap command scriptlet in an invocation of sh
export PLUGIN_CMD="sh -c '${PLUGIN_CMD}'"
Expand Down

0 comments on commit 59b7f13

Please sign in to comment.