From c3b5bb929ee585df6484830ccfe254a1f38d906f Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Tue, 25 Oct 2016 22:35:30 +0200 Subject: [PATCH 1/1] Bugfix: escape I3_VERSION when read from file (#2517) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit I3_VERSION is used as string literal in config.h, i.e.: #define I3_VERSION … Where “…” is replaced with the contents of I3_VERSION. For our travis builds, we persist the version number to I3_VERSION, i.e.: $ cat I3_VERSION 4.12-150-g8ddc187 (2016-10-25, branch "next") Previously, config.h would end up with: #define I3_VERSION "4.12-150-g8ddc187 (2016-10-25, branch "next")" Note the unquoted double quotes around “next”, which are invalid in C string literals. Hence, this commit uses sed to escape double quotes, question marks and backslashes (see also http://stackoverflow.com/a/12208808/712014). The @<:@ and @:>@ quadrigraphs that m4 expands to [ and ], respectively, see also http://stackoverflow.com/a/2309394/712014 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 3c47c6b5..8829fed9 100644 --- a/configure.ac +++ b/configure.ac @@ -32,7 +32,7 @@ AS_IF([test -d ${srcdir}/.git], ], [ VERSION="$(cut -d '-' -f 1 ${srcdir}/I3_VERSION | cut -d ' ' -f 1)" - I3_VERSION="$(cat ${srcdir}/I3_VERSION)" + I3_VERSION="$(sed -e 's/@<:@\"?\\@:>@/\\&/g' ${srcdir}/I3_VERSION)" is_release="$(grep -q non-git ${srcdir}/I3_VERSION && echo no || echo yes)" ]) AC_SUBST([I3_VERSION], [$I3_VERSION]) -- 2.39.5