From 95ee1fa0303fc72ca10f594db5b1c4a8551fed3d Mon Sep 17 00:00:00 2001 From: Jonas Nick Date: Wed, 15 Sep 2021 20:09:35 +0000 Subject: [PATCH] sync-upstream: fix quoting Otherwise strings in $TITLE and $BODAY that are enclosed in ` are executed in gh-pr-create.sh. --- contrib/sync-upstream.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/contrib/sync-upstream.sh b/contrib/sync-upstream.sh index 55dde4e1..b72744f4 100755 --- a/contrib/sync-upstream.sh +++ b/contrib/sync-upstream.sh @@ -100,11 +100,20 @@ git checkout master git pull git checkout -b temp-merge-"$PRNUM" +# Escape single quote +# ' -> '\'' +quote() { + local quoted=${1//\'/\'\\\'\'} + printf "%s" "$quoted" +} +TITLE=$(quote "$TITLE") +BODY=$(quote "$BODY") + BASEDIR=$(dirname "$0") FNAME="$BASEDIR/gh-pr-create.sh" cat < "$FNAME" #!/bin/sh -gh pr create -t "$TITLE" -b "$BODY" --web +gh pr create -t '$TITLE' -b '$BODY' --web # Remove temporary branch git checkout master git branch -D temp-merge-"$PRNUM"