Skip to content

Instantly share code, notes, and snippets.

@runeksvendsen
Created August 6, 2014 05:13
Show Gist options
  • Save runeksvendsen/c9fc65d1241cd3d348b3 to your computer and use it in GitHub Desktop.
Save runeksvendsen/c9fc65d1241cd3d348b3 to your computer and use it in GitHub Desktop.
Fix sed error when $1, $2 or $3 contain special characters
diff --git a/scripts/debian-update-versions b/scripts/debian-update-versions
index ae24849..dcdc76c 100755
--- a/scripts/debian-update-versions
+++ b/scripts/debian-update-versions
@@ -20,8 +20,11 @@ get_timestamp_commit()
}
do_subst() {
- sed -e "0,/^mpv (.*)/s/(.*)/($1)/" \
- -e "s/^ \* local build.*/ \* local build with ffmpeg $2, libass $3/" \
+ parm1=$(echo "$1"|sed -e 's/[\/&]/\\&/g')
+ parm2=$(echo "$2"|sed -e 's/[\/&]/\\&/g')
+ parm3=$(echo "$3"|sed -e 's/[\/&]/\\&/g')
+ sed -e "0,/^mpv (.*)/s/(.*)/($parm1)/" \
+ -e "s/^ \* local build.*/ \* local build with ffmpeg $parm2, libass $parm3/" \
-e"s/\(^ -- Local User <localuser@localhost>\).*/\1 $(date -R)/" debian/changelog.TEMPLATE > debian/changelog
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment