[FFmpeg-devel] [RFC/PATCH]Allow to use ancient bash to make version.h

Carl Eugen Hoyos cehoyos at ag.or.at
Thu Jun 19 18:58:50 CEST 2014


Hi!

A user reported that Solaris / Oracle /bin/sh does not allow to build 
version.h. I was able to reproduce this with heirloom-sh from 
http://heirloom.sourceforge.net/sh.html
Attached patch fixes the issue here, also tested with bash, ksh and dash.

Please comment, Carl Eugen

$ sh version.sh .
version.sh: syntax error at line 7: `revision=$' unexpected
-------------- next part --------------
diff --git a/version.sh b/version.sh
index 92edcb9..139795f 100755
--- a/version.sh
+++ b/version.sh
@@ -3,19 +3,18 @@
 # Usage: version.sh <ffmpeg-root-dir> <output-version.h> <extra-version>
 
 # check for git short hash
-if ! test "$revision"; then
-    revision=$(cd "$1" && git describe --tags --match N 2> /dev/null)
-fi
+test "$revision" ||
+    revision=`cd "$1" && git describe --tags --match N 2> /dev/null`
 
 # Shallow Git clones (--depth) do not have the N tag:
 # use 'git-YYYY-MM-DD-hhhhhhh'.
-test "$revision" || revision=$(cd "$1" &&
-  git log -1 --pretty=format:"git-%cd-%h" --date=short 2> /dev/null)
+test "$revision" || revision=`cd "$1" &&
+  git log -1 --pretty=format:"git-%cd-%h" --date=short 2> /dev/null`
 
 # Snapshots from gitweb are in a directory called ffmpeg-hhhhhhh or
 # ffmpeg-HEAD-hhhhhhh.
 if [ -z "$revision" ]; then
-  srcdir=$(cd "$1" && pwd)
+  srcdir=`cd "$1" && pwd`
   case "$srcdir" in
     */ffmpeg-[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f])
       git_hash="${srcdir##*-}";;
@@ -25,13 +24,13 @@ if [ -z "$revision" ]; then
 fi
 
 # no revision number found
-test "$revision" || revision=$(cd "$1" && cat RELEASE 2> /dev/null)
+test "$revision" || revision=`cd "$1" && cat RELEASE 2> /dev/null`
 
 # Append the Git hash if we have one
 test "$revision" && test "$git_hash" && revision="$revision-$git_hash"
 
 # releases extract the version number from the VERSION file
-version=$(cd "$1" && cat VERSION 2> /dev/null)
+version=`cd "$1" && cat VERSION 2> /dev/null`
 test "$version" || version=$revision
 
 test -n "$3" && version=$version-$3
@@ -42,10 +41,10 @@ if [ -z "$2" ]; then
 fi
 
 NEW_REVISION="#define FFMPEG_VERSION \"$version\""
-OLD_REVISION=$(cat "$2" 2> /dev/null | head -3 | tail -1)
+OLD_REVISION=`cat "$2" 2> /dev/null | head -3 | tail -1`
 
 # String used for preprocessor guard
-GUARD=$(echo "$2" | sed 's/\//_/' | sed 's/\./_/' | tr '[:lower:]' '[:upper:]' | sed 's/LIB//')
+GUARD=`echo "$2" | sed 's/\//_/' | sed 's/\./_/' | tr '[:lower:]' '[:upper:]' | sed 's/LIB//'`
 
 # Update version header only on revision changes to avoid spurious rebuilds
 if test "$NEW_REVISION" != "$OLD_REVISION"; then


More information about the ffmpeg-devel mailing list