[PATCH] Fix typos and shell for MacOSX packaging scripts

Cristian Ionescu-Idbohrn cristian.ionescu-idbohrn at axis.com
Tue Oct 2 16:15:02 PDT 2012


On Tue, 2 Oct 2012, Dirk Hohndel wrote:
> Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn at axis.com> writes:
> > On Tue, 2 Oct 2012, Dirk Hohndel wrote:
> >> On Oct 2, 2012, at 2:00 AM, Cristian Ionescu-Idbohrn wrote:
> >> > On Tue, 2 Oct 2012, Henrik Brautaset Aronsen wrote:
> >> >> Den 02.10.12 10:32, skrev Cristian Ionescu-Idbohrn:
> >> >>> On Tue, 2 Oct 2012, Henrik Brautaset Aronsen wrote:
> >> >>>> /bin/sh can be "anything", so I've forced /bin/bash for good
> >> >>>> measure.
> >> >>> What do you mean with "good measure"?  That script should be
> >> >>> portable, ie. work with any posix shell, shouldn't it?
> >> >>
> >> >> This doesn't have to be very portable, since it's supposed to run on
> >> >> MacOSX. Apple has changed /bin/sh earlier, I just thought it would
> >> >> be smart to fix the shell to something that's known to work.
> >> >
> >> > To be honest, I don't really care too much about MacOSX but, as a
> >> > matter of principal, the "smarter" way to have scripts work with any
> >> > posix shell is to write portable code.  Even on MacOSX ;)  If Apple
> >> > breaks the shell, than more than packaging scripts will be broken
> >> > anyway.
> >>
> >> Heh. Should have read through all the emails, first.
> >>
> >> I agree with Cristian - I'd rather have a really portable script.
> >> Could someone who is more familiar with POSIX shell limitations take a
> >> look and make sure that packaging/macos/subsurface.sh is portable,
> >> please?
> >
> > I'll take a look at that tonight and maybe get back with a patch, if
> > needed.  But bear in mind that I have no way to test it on a MacOSX.
>
> That's fine. I'm just by no stretch of the imagination an expert when it
> comes to POSIX shell syntax and limitations. So all I'm hoping for is
> someone with more experience on that front to take a look at the script
> and make sure that it doesn't ask too much of a shell.

Here's an incipient cleanup attempt, maybe controversial.  Should I
continue?

commit 29cae14b23a14833de32749e530cc590e8136f88
Author: Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn at axis.com>
Date:   Tue Oct 2 19:28:25 2012 +0200

    Tabify and split long comment lines.

    Also, make the comments syntax uniform.

    Signed-off-by: Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn at axis.com>

diff --git a/packaging/macosx/subsurface.sh b/packaging/macosx/subsurface.sh
index ad0bdbd..6fff86c 100755
--- a/packaging/macosx/subsurface.sh
+++ b/packaging/macosx/subsurface.sh
@@ -1,13 +1,13 @@
 #!/bin/sh

 if test "x$GTK_DEBUG_LAUNCHER" != x; then
-    set -x
+	set -x
 fi

 if test "x$GTK_DEBUG_GDB" != x; then
-    EXEC="gdb --args"
+	EXEC="gdb --args"
 else
-    EXEC=exec
+	EXEC=exec
 fi

 name=`basename "$0"`
@@ -41,46 +41,48 @@ unset LANG LC_MESSAGES LC_MONETARY LC_COLLATE

 # Has a language ordering been set?
 # If so, set LC_MESSAGES and LANG accordingly; otherwise skip it.
-# First step uses sed to clean off the quotes and commas, to change - to _, and change the names for the chinese scripts from "Hans" to CN and "Hant" to TW.
+# First step uses sed to clean off the quotes and commas, to change - to _, and
+# change the names for the chinese scripts from "Hans" to CN and "Hant" to TW.
 APPLELANGUAGES=`defaults read .GlobalPreferences AppleLanguages | sed -En   -e 's/\-/_/' -e 's/Hant/TW/' -e 's/Hans/CN/' -e 's/[[:space:]]*\"?([[:alnum:]_]+)\"?,?/\1/p' `
 if test "$APPLELANGUAGES"; then
-    # A language ordering exists.
-    # Test, item per item, to see whether there is an corresponding locale.
-    for L in $APPLELANGUAGES; do
-	#test for exact matches:
-       if test -f "$I18NDIR/${L}/LC_MESSAGES/$APP.mo"; then
-	    export LANG=$L
-            break
-        fi
-	#This is a special case, because often the original strings are in US
-	#English and there is no translation file.
-	if test "x$L" == "xen_US"; then
-	    export LANG=$L
-	    break
-	fi
-	#OK, now test for just the first two letters:
-        if test -f "$I18NDIR/${L:0:2}/LC_MESSAGES/$APP.mo"; then
-	    export LANG=${L:0:2}
-	    break
-	fi
-	#Same thing, but checking for any english variant.
-	if test "x${L:0:2}" == "xen"; then
-	    export LANG=$L
-	    break
-	fi;
-    done
+	# A language ordering exists.
+	# Test, item per item, to see whether there is an corresponding locale.
+	for L in $APPLELANGUAGES; do
+		#test for exact matches:
+		if test -f "$I18NDIR/${L}/LC_MESSAGES/$APP.mo"; then
+			export LANG=$L
+			break
+		fi
+		# This is a special case, because often the original strings
+		# are in US English and there is no translation file.
+		if test "x$L" == "xen_US"; then
+			export LANG=$L
+			break
+		fi
+		# OK, now test for just the first two letters:
+		if test -f "$I18NDIR/${L:0:2}/LC_MESSAGES/$APP.mo"; then
+			export LANG=${L:0:2}
+			break
+		fi
+		# Same thing, but checking for any english variant.
+		if test "x${L:0:2}" == "xen"; then
+			export LANG=$L
+			break
+		fi;
+	done
 fi
 unset APPLELANGUAGES L

-# If we didn't get a language from the language list, try the Collation preference, in case it's the only setting that exists.
+# If we didn't get a language from the language list, try the Collation
+# preference, in case it's the only setting that exists.
 APPLECOLLATION=`defaults read .GlobalPreferences AppleCollationOrder`
 if test -z ${LANG} -a -n $APPLECOLLATION; then
-    if test -f "$I18NDIR/${APPLECOLLATION:0:2}/LC_MESSAGES/$APP.mo"; then
-	export LANG=${APPLECOLLATION:0:2}
-    fi
+	if test -f "$I18NDIR/${APPLECOLLATION:0:2}/LC_MESSAGES/$APP.mo"; then
+		export LANG=${APPLECOLLATION:0:2}
+	fi
 fi
 if test ! -z $APPLECOLLATION; then
-    export LC_COLLATE=$APPLECOLLATION
+	export LC_COLLATE=$APPLECOLLATION
 fi
 unset APPLECOLLATION

@@ -88,81 +90,83 @@ unset APPLECOLLATION
 APPLELOCALE=`defaults read .GlobalPreferences AppleLocale`

 if test -f "$I18NDIR/${APPLELOCALE:0:5}/LC_MESSAGES/$APP.mo"; then
-    if test -z $LANG; then
-        export LANG="${APPLELOCALE:0:5}"
-    fi
+	if test -z $LANG; then
+		export LANG="${APPLELOCALE:0:5}"
+	fi

 elif test -z $LANG -a -f "$I18NDIR/${APPLELOCALE:0:2}/LC_MESSAGES/$APP.mo"; then
-    export LANG="${APPLELOCALE:0:2}"
+	export LANG="${APPLELOCALE:0:2}"
 fi

-#Next we need to set LC_MESSAGES. If at all possilbe, we want a full
-#5-character locale to avoid the "Locale not supported by C library"
-#warning from Gtk -- even though Gtk will translate with a
-#two-character code.
+# Next we need to set LC_MESSAGES. If at all possilbe, we want a full
+# 5-character locale to avoid the "Locale not supported by C library"
+# warning from Gtk -- even though Gtk will translate with a
+# two-character code.
 if test -n $LANG; then
-#If the language code matches the applelocale, then that's the message
-#locale; otherwise, if it's longer than two characters, then it's
-#probably a good message locale and we'll go with it.
-    if test $LANG == ${APPLELOCALE:0:5} -o $LANG != ${LANG:0:2}; then
-	export LC_MESSAGES=$LANG
-#Next try if the Applelocale is longer than 2 chars and the language
-#bit matches $LANG
-    elif test $LANG == ${APPLELOCALE:0:2} -a $APPLELOCALE > ${APPLELOCALE:0:2}; then
-	export LC_MESSAGES=${APPLELOCALE:0:5}
-#Fail. Get a list of the locales in $PREFIX/share/locale that match
-#our two letter language code and pick the first one, special casing
-#english to set en_US
-    elif test $LANG == "en"; then
-	export LC_MESSAGES="en_US"
-    else
-	LOC=`find $PREFIX/share/locale -name $LANG???`
-	for L in $LOC; do
-	    export LC_MESSAGES=$L
-	done
-    fi
+	# If the language code matches the applelocale, then that's the message
+	# locale; otherwise, if it's longer than two characters, then it's
+	# probably a good message locale and we'll go with it.
+	if test $LANG == ${APPLELOCALE:0:5} -o $LANG != ${LANG:0:2}; then
+		export LC_MESSAGES=$LANG
+		# Next try if the Applelocale is longer than 2 chars and the
+		# language bit matches $LANG
+	elif test $LANG == ${APPLELOCALE:0:2} -a $APPLELOCALE > ${APPLELOCALE:0:2}; then
+		export LC_MESSAGES=${APPLELOCALE:0:5}
+		# Fail. Get a list of the locales in $PREFIX/share/locale that
+		# match our two letter language code and pick the first one,
+		# special casing english to set en_US
+	elif test $LANG == "en"; then
+		export LC_MESSAGES="en_US"
+	else
+		LOC=`find $PREFIX/share/locale -name $LANG???`
+		for L in $LOC; do
+			export LC_MESSAGES=$L
+		done
+	fi
 else
-#All efforts have failed, so default to US english
-    export LANG="en_US"
-    export LC_MESSAGES="en_US"
+	# All efforts have failed, so default to US english
+	export LANG="en_US"
+	export LC_MESSAGES="en_US"
 fi
 CURRENCY=`echo $APPLELOCALE |  sed -En 's/.*currency=([[:alpha:]]+).*/\1/p'`
 if test "x$CURRENCY" != "x"; then
-#The user has set a special currency. Gtk doesn't install LC_MONETARY files, but Apple does in /usr/share/locale, so we're going to look there for a locale to set LC_CURRENCY to.
-    if test -f /usr/local/share/$LC_MESSAGES/LC_MONETARY; then
-	if test -a `cat /usr/local/share/$LC_MESSAGES/LC_MONETARY` == $CURRENCY; then
-	    export LC_MONETARY=$LC_MESSAGES
+	# The user has set a special currency. Gtk doesn't install LC_MONETARY
+	# files, but Apple does in /usr/share/locale, so we're going to look
+	# there for a locale to set LC_CURRENCY to.
+	if test -f /usr/local/share/$LC_MESSAGES/LC_MONETARY; then
+		if test -a `cat /usr/local/share/$LC_MESSAGES/LC_MONETARY` == $CURRENCY; then
+			export LC_MONETARY=$LC_MESSAGES
+		fi
 	fi
-    fi
-    if test -z "$LC_MONETARY"; then
-	FILES=`find /usr/share/locale -name LC_MONETARY -exec grep -H $CURRENCY {} \;`
-	if test -n "$FILES"; then
-	    export LC_MONETARY=`echo $FILES | sed -En 's%/usr/share/locale/([[:alpha:]_]+)/LC_MONETARY.*%\1%p'`
+	if test -z "$LC_MONETARY"; then
+		FILES=`find /usr/share/locale -name LC_MONETARY -exec grep -H $CURRENCY {} \;`
+		if test -n "$FILES"; then
+			export LC_MONETARY=`echo $FILES | sed -En 's%/usr/share/locale/([[:alpha:]_]+)/LC_MONETARY.*%\1%p'`
+		fi
 	fi
-    fi
 fi
-#No currency value means that the AppleLocale governs:
+# No currency value means that the AppleLocale governs:
 if test -z "$LC_MONETARY"; then
-    LC_MONETARY=${APPLELOCALE:0:5}
+	LC_MONETARY=${APPLELOCALE:0:5}
 fi
-#For Gtk, which only looks at LC_ALL:
+# For Gtk, which only looks at LC_ALL:
 export LC_ALL=$LC_MESSAGES

 unset APPLELOCALE FILES LOC

 if test -f "$bundle_lib/charset.alias"; then
-    export CHARSETALIASDIR="$bundle_lib"
+	export CHARSETALIASDIR="$bundle_lib"
 fi

 # Extra arguments can be added in environment.sh.
 EXTRA_ARGS=
 if test -f "$bundle_res/environment.sh"; then
-  source "$bundle_res/environment.sh"
+	source "$bundle_res/environment.sh"
 fi

 # Strip out the argument added by the OS.
 if /bin/expr "x$1" : '^x-psn_' > /dev/null; then
-    shift 1
+	shift 1
 fi

 $EXEC "$bundle_contents/MacOS/$name-bin" "$@" $EXTRA_ARGS

commit 1392086de4347aa96b137c126c09da8ba10ab798
Author: Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn at axis.com>
Date:   Tue Oct 2 20:28:50 2012 +0200

    Remove/mark bashisms.

    Signed-off-by: Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn at axis.com>

diff --git a/packaging/macosx/subsurface.sh b/packaging/macosx/subsurface.sh
index 6fff86c..0ca3186 100755
--- a/packaging/macosx/subsurface.sh
+++ b/packaging/macosx/subsurface.sh
@@ -55,17 +55,20 @@ if test "$APPLELANGUAGES"; then
 		fi
 		# This is a special case, because often the original strings
 		# are in US English and there is no translation file.
-		if test "x$L" == "xen_US"; then
+		if test "x$L" = "xen_US"; then
 			export LANG=$L
 			break
 		fi
 		# OK, now test for just the first two letters:
+		# FIXME: bashism
 		if test -f "$I18NDIR/${L:0:2}/LC_MESSAGES/$APP.mo"; then
+			# FIXME: bashism
 			export LANG=${L:0:2}
 			break
 		fi
 		# Same thing, but checking for any english variant.
-		if test "x${L:0:2}" == "xen"; then
+		# FIXME: bashism
+		if test "x${L:0:2}" = "xen"; then
 			export LANG=$L
 			break
 		fi;
@@ -76,8 +79,10 @@ unset APPLELANGUAGES L
 # If we didn't get a language from the language list, try the Collation
 # preference, in case it's the only setting that exists.
 APPLECOLLATION=`defaults read .GlobalPreferences AppleCollationOrder`
-if test -z ${LANG} -a -n $APPLECOLLATION; then
+if test -z ${LANG} && "$APPLECOLLATION"; then
+	# FIXME: bashism
 	if test -f "$I18NDIR/${APPLECOLLATION:0:2}/LC_MESSAGES/$APP.mo"; then
+		# FIXME: bashism
 		export LANG=${APPLECOLLATION:0:2}
 	fi
 fi
@@ -89,12 +94,15 @@ unset APPLECOLLATION
 # Continue by attempting to find the Locale preference.
 APPLELOCALE=`defaults read .GlobalPreferences AppleLocale`

+# FIXME: bashism
 if test -f "$I18NDIR/${APPLELOCALE:0:5}/LC_MESSAGES/$APP.mo"; then
 	if test -z $LANG; then
+		# FIXME: bashism
 		export LANG="${APPLELOCALE:0:5}"
 	fi
-
-elif test -z $LANG -a -f "$I18NDIR/${APPLELOCALE:0:2}/LC_MESSAGES/$APP.mo"; then
+# FIXME: bashism
+elif test -z $LANG && -f "$I18NDIR/${APPLELOCALE:0:2}/LC_MESSAGES/$APP.mo"; then
+	# FIXME: bashism
 	export LANG="${APPLELOCALE:0:2}"
 fi

@@ -106,16 +114,19 @@ if test -n $LANG; then
 	# If the language code matches the applelocale, then that's the message
 	# locale; otherwise, if it's longer than two characters, then it's
 	# probably a good message locale and we'll go with it.
-	if test $LANG == ${APPLELOCALE:0:5} -o $LANG != ${LANG:0:2}; then
+	# FIXME: bashisms
+	if test $LANG = ${APPLELOCALE:0:5} || $LANG != ${LANG:0:2}; then
 		export LC_MESSAGES=$LANG
 		# Next try if the Applelocale is longer than 2 chars and the
 		# language bit matches $LANG
-	elif test $LANG == ${APPLELOCALE:0:2} -a $APPLELOCALE > ${APPLELOCALE:0:2}; then
+	# FIXME: bashism
+	elif test $LANG = ${APPLELOCALE:0:2} && $APPLELOCALE > ${APPLELOCALE:0:2}; then
+		# FIXME: bashism
 		export LC_MESSAGES=${APPLELOCALE:0:5}
 		# Fail. Get a list of the locales in $PREFIX/share/locale that
 		# match our two letter language code and pick the first one,
 		# special casing english to set en_US
-	elif test $LANG == "en"; then
+	elif test $LANG = "en"; then
 		export LC_MESSAGES="en_US"
 	else
 		LOC=`find $PREFIX/share/locale -name $LANG???`
@@ -134,7 +145,7 @@ if test "x$CURRENCY" != "x"; then
 	# files, but Apple does in /usr/share/locale, so we're going to look
 	# there for a locale to set LC_CURRENCY to.
 	if test -f /usr/local/share/$LC_MESSAGES/LC_MONETARY; then
-		if test -a `cat /usr/local/share/$LC_MESSAGES/LC_MONETARY` == $CURRENCY; then
+		if test `cat /usr/local/share/$LC_MESSAGES/LC_MONETARY` = $CURRENCY; then
 			export LC_MONETARY=$LC_MESSAGES
 		fi
 	fi
@@ -147,6 +158,7 @@ if test "x$CURRENCY" != "x"; then
 fi
 # No currency value means that the AppleLocale governs:
 if test -z "$LC_MONETARY"; then
+	# FIXME: bashism
 	LC_MONETARY=${APPLELOCALE:0:5}
 fi
 # For Gtk, which only looks at LC_ALL:
@@ -161,7 +173,7 @@ fi
 # Extra arguments can be added in environment.sh.
 EXTRA_ARGS=
 if test -f "$bundle_res/environment.sh"; then
-	source "$bundle_res/environment.sh"
+	. "$bundle_res/environment.sh"
 fi

 # Strip out the argument added by the OS.

commit 3607395f55d5861092957c1c127fa9977cd8aafe
Author: Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn at axis.com>
Date:   Tue Oct 2 23:19:17 2012 +0200

    Remove totally usless quotes.

    Is there anyone out there using a 1984 sunOS to build on MacOS?

    Signed-off-by: Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn at axis.com>

diff --git a/packaging/macosx/subsurface.sh b/packaging/macosx/subsurface.sh
index 0ca3186..e36f887 100755
--- a/packaging/macosx/subsurface.sh
+++ b/packaging/macosx/subsurface.sh
@@ -11,31 +11,31 @@ else
 fi

 name=`basename "$0"`
-tmp="$0"
+tmp=$0
 tmp=`dirname "$tmp"`
 tmp=`dirname "$tmp"`
 bundle=`dirname "$tmp"`
-bundle_contents="$bundle"/Contents
-bundle_res="$bundle_contents"/Resources
-bundle_lib="$bundle_res"/lib
-bundle_bin="$bundle_res"/bin
-bundle_data="$bundle_res"/share
-bundle_etc="$bundle_res"/etc
+bundle_contents=$bundle/Contents
+bundle_res=$bundle_contents/Resources
+bundle_lib=$bundle_res/lib
+bundle_bin=$bundle_res/bin
+bundle_data=$bundle_res/share
+bundle_etc=$bundle_res/etc

 #export DYLD_LIBRARY_PATH="$bundle_lib"
-export XDG_CONFIG_DIRS="$bundle_etc"/xdg
-export XDG_DATA_DIRS="$bundle_data"
-export GTK_DATA_PREFIX="$bundle_res"
-export GTK_EXE_PREFIX="$bundle_res"
-export GTK_PATH="$bundle_res"
+export XDG_CONFIG_DIRS=$bundle_etc/xdg
+export XDG_DATA_DIRS=$bundle_data
+export GTK_DATA_PREFIX=$bundle_res
+export GTK_EXE_PREFIX=$bundle_res
+export GTK_PATH=$bundle_res

-export GTK2_RC_FILES="$bundle_etc/gtk-2.0/gtkrc"
-export GTK_IM_MODULE_FILE="$bundle_etc/gtk-2.0/gtk.immodules"
-export GDK_PIXBUF_MODULE_FILE="$bundle_etc/gtk-2.0/gdk-pixbuf.loaders"
-export PANGO_RC_FILE="$bundle_etc/pango/pangorc"
+export GTK2_RC_FILES=$bundle_etc/gtk-2.0/gtkrc
+export GTK_IM_MODULE_FILE=$bundle_etc/gtk-2.0/gtk.immodules
+export GDK_PIXBUF_MODULE_FILE=$bundle_etc/gtk-2.0/gdk-pixbuf.loaders
+export PANGO_RC_FILE=$bundle_etc/pango/pangorc

 APP=name
-I18NDIR="$bundle_data/locale"
+I18NDIR=$bundle_data/locale
 # Set the locale-related variables appropriately:
 unset LANG LC_MESSAGES LC_MONETARY LC_COLLATE

@@ -55,7 +55,7 @@ if test "$APPLELANGUAGES"; then
 		fi
 		# This is a special case, because often the original strings
 		# are in US English and there is no translation file.
-		if test "x$L" = "xen_US"; then
+		if test "$L" = en_US; then
 			export LANG=$L
 			break
 		fi
@@ -68,7 +68,7 @@ if test "$APPLELANGUAGES"; then
 		fi
 		# Same thing, but checking for any english variant.
 		# FIXME: bashism
-		if test "x${L:0:2}" = "xen"; then
+		if test "${L:0:2}" = en; then
 			export LANG=$L
 			break
 		fi;
@@ -79,7 +79,7 @@ unset APPLELANGUAGES L
 # If we didn't get a language from the language list, try the Collation
 # preference, in case it's the only setting that exists.
 APPLECOLLATION=`defaults read .GlobalPreferences AppleCollationOrder`
-if test -z ${LANG} && "$APPLECOLLATION"; then
+if test -z "$LANG" && "$APPLECOLLATION"; then
 	# FIXME: bashism
 	if test -f "$I18NDIR/${APPLECOLLATION:0:2}/LC_MESSAGES/$APP.mo"; then
 		# FIXME: bashism
@@ -96,37 +96,37 @@ APPLELOCALE=`defaults read .GlobalPreferences AppleLocale`

 # FIXME: bashism
 if test -f "$I18NDIR/${APPLELOCALE:0:5}/LC_MESSAGES/$APP.mo"; then
-	if test -z $LANG; then
+	if test -z "$LANG"; then
 		# FIXME: bashism
-		export LANG="${APPLELOCALE:0:5}"
+		export LANG=${APPLELOCALE:0:5}
 	fi
 # FIXME: bashism
-elif test -z $LANG && -f "$I18NDIR/${APPLELOCALE:0:2}/LC_MESSAGES/$APP.mo"; then
+elif test -z "$LANG" && -f "$I18NDIR/${APPLELOCALE:0:2}/LC_MESSAGES/$APP.mo"; then
 	# FIXME: bashism
-	export LANG="${APPLELOCALE:0:2}"
+	export LANG=${APPLELOCALE:0:2}
 fi

 # Next we need to set LC_MESSAGES. If at all possilbe, we want a full
 # 5-character locale to avoid the "Locale not supported by C library"
 # warning from Gtk -- even though Gtk will translate with a
 # two-character code.
-if test -n $LANG; then
+if test "$LANG"; then
 	# If the language code matches the applelocale, then that's the message
 	# locale; otherwise, if it's longer than two characters, then it's
 	# probably a good message locale and we'll go with it.
 	# FIXME: bashisms
-	if test $LANG = ${APPLELOCALE:0:5} || $LANG != ${LANG:0:2}; then
+	if test "$LANG" = ${APPLELOCALE:0:5} || "$LANG" != ${LANG:0:2}; then
 		export LC_MESSAGES=$LANG
 		# Next try if the Applelocale is longer than 2 chars and the
 		# language bit matches $LANG
 	# FIXME: bashism
-	elif test $LANG = ${APPLELOCALE:0:2} && $APPLELOCALE > ${APPLELOCALE:0:2}; then
+	elif test "$LANG" = ${APPLELOCALE:0:2} && $APPLELOCALE > ${APPLELOCALE:0:2}; then
 		# FIXME: bashism
 		export LC_MESSAGES=${APPLELOCALE:0:5}
 		# Fail. Get a list of the locales in $PREFIX/share/locale that
 		# match our two letter language code and pick the first one,
 		# special casing english to set en_US
-	elif test $LANG = "en"; then
+	elif test "$LANG" = en; then
 		export LC_MESSAGES="en_US"
 	else
 		LOC=`find $PREFIX/share/locale -name $LANG???`
@@ -136,11 +136,11 @@ if test -n $LANG; then
 	fi
 else
 	# All efforts have failed, so default to US english
-	export LANG="en_US"
-	export LC_MESSAGES="en_US"
+	export LANG=en_US
+	export LC_MESSAGES=en_US
 fi
 CURRENCY=`echo $APPLELOCALE |  sed -En 's/.*currency=([[:alpha:]]+).*/\1/p'`
-if test "x$CURRENCY" != "x"; then
+if test "$CURRENCY" then
 	# The user has set a special currency. Gtk doesn't install LC_MONETARY
 	# files, but Apple does in /usr/share/locale, so we're going to look
 	# there for a locale to set LC_CURRENCY to.
@@ -151,7 +151,7 @@ if test "x$CURRENCY" != "x"; then
 	fi
 	if test -z "$LC_MONETARY"; then
 		FILES=`find /usr/share/locale -name LC_MONETARY -exec grep -H $CURRENCY {} \;`
-		if test -n "$FILES"; then
+		if test "$FILES"; then
 			export LC_MONETARY=`echo $FILES | sed -En 's%/usr/share/locale/([[:alpha:]_]+)/LC_MONETARY.*%\1%p'`
 		fi
 	fi
@@ -167,7 +167,7 @@ export LC_ALL=$LC_MESSAGES
 unset APPLELOCALE FILES LOC

 if test -f "$bundle_lib/charset.alias"; then
-	export CHARSETALIASDIR="$bundle_lib"
+	export CHARSETALIASDIR=$bundle_lib
 fi

 # Extra arguments can be added in environment.sh.

commit efa95b7c20bf4657ddca83636f51415e2acdbdac
Author: Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn at axis.com>
Date:   Wed Oct 3 00:36:15 2012 +0200

    Along the same lines, but simplier.

    Signed-off-by: Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn at axis.com>

diff --git a/packaging/macosx/subsurface.sh b/packaging/macosx/subsurface.sh
index e36f887..f11ca26 100755
--- a/packaging/macosx/subsurface.sh
+++ b/packaging/macosx/subsurface.sh
@@ -1,6 +1,6 @@
 #!/bin/sh

-if test "x$GTK_DEBUG_LAUNCHER" != x; then
+if test "$GTK_DEBUG_LAUNCHER"; then
 	set -x
 fi


commit 7e93481a2e643549b54f016802d6fb0a5af8407f
Author: Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn at axis.com>
Date:   Wed Oct 3 00:37:35 2012 +0200

    Even more so.

    Signed-off-by: Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn at axis.com>

diff --git a/packaging/macosx/subsurface.sh b/packaging/macosx/subsurface.sh
index f11ca26..d920fe3 100755
--- a/packaging/macosx/subsurface.sh
+++ b/packaging/macosx/subsurface.sh
@@ -1,8 +1,6 @@
 #!/bin/sh

-if test "$GTK_DEBUG_LAUNCHER"; then
-	set -x
-fi
+! test "$GTK_DEBUG_LAUNCHER" || set -x

 if test "x$GTK_DEBUG_GDB" != x; then
 	EXEC="gdb --args"

commit 493df974d5e15c2197294e86c58dcadbc7ca4d9a
Author: Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn at axis.com>
Date:   Wed Oct 3 00:41:42 2012 +0200

    Skip forks.  There's still something orr there...

    Signed-off-by: Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn at axis.com>

diff --git a/packaging/macosx/subsurface.sh b/packaging/macosx/subsurface.sh
index d920fe3..0ae89d0 100755
--- a/packaging/macosx/subsurface.sh
+++ b/packaging/macosx/subsurface.sh
@@ -8,9 +8,9 @@ else
 	EXEC=exec
 fi

-name=`basename "$0"`
+name=${0##*/}
 tmp=$0
-tmp=`dirname "$tmp"`
+tmp=${tmp%/*}
 tmp=`dirname "$tmp"`
 bundle=`dirname "$tmp"`
 bundle_contents=$bundle/Contents

commit f233069a2d40b0b1aec2b082bc3e3186363466b1
Author: Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn at axis.com>
Date:   Wed Oct 3 00:52:29 2012 +0200

    Remove repeated dir strip forks.

    Signed-off-by: Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn at axis.com>

diff --git a/packaging/macosx/subsurface.sh b/packaging/macosx/subsurface.sh
index 0ae89d0..eea1a9a 100755
--- a/packaging/macosx/subsurface.sh
+++ b/packaging/macosx/subsurface.sh
@@ -11,8 +11,8 @@ fi
 name=${0##*/}
 tmp=$0
 tmp=${tmp%/*}
-tmp=`dirname "$tmp"`
-bundle=`dirname "$tmp"`
+tmp=${tmp%/*}
+bundle=${tmp%/*}
 bundle_contents=$bundle/Contents
 bundle_res=$bundle_contents/Resources
 bundle_lib=$bundle_res/lib

commit 51412ee0b1d08a0d28bea58f6fd0de3e3fc618d9
Author: Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn at axis.com>
Date:   Wed Oct 3 00:58:52 2012 +0200

    [:space:] and [:blank:] classes are somewhat different beasts.

    Signed-off-by: Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn at axis.com>

diff --git a/packaging/macosx/subsurface.sh b/packaging/macosx/subsurface.sh
index eea1a9a..8cb868c 100755
--- a/packaging/macosx/subsurface.sh
+++ b/packaging/macosx/subsurface.sh
@@ -41,7 +41,7 @@ unset LANG LC_MESSAGES LC_MONETARY LC_COLLATE
 # If so, set LC_MESSAGES and LANG accordingly; otherwise skip it.
 # First step uses sed to clean off the quotes and commas, to change - to _, and
 # change the names for the chinese scripts from "Hans" to CN and "Hant" to TW.
-APPLELANGUAGES=`defaults read .GlobalPreferences AppleLanguages | sed -En   -e 's/\-/_/' -e 's/Hant/TW/' -e 's/Hans/CN/' -e 's/[[:space:]]*\"?([[:alnum:]_]+)\"?,?/\1/p' `
+APPLELANGUAGES=`defaults read .GlobalPreferences AppleLanguages | sed -En  -e 's/\-/_/' -e 's/Hant/TW/' -e 's/Hans/CN/' -e 's/[[:blank:]]*\"?([[:alnum:]_]+)\"?,?/\1/p' `
 if test "$APPLELANGUAGES"; then
 	# A language ordering exists.
 	# Test, item per item, to see whether there is an corresponding locale.

commit ce0aefdd5f4e254abfd780e65ed806919de2459b
Author: Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn at axis.com>
Date:   Wed Oct 3 01:06:17 2012 +0200

    Simplify.

    Signed-off-by: Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn at axis.com>

diff --git a/packaging/macosx/subsurface.sh b/packaging/macosx/subsurface.sh
index 8cb868c..e285406 100755
--- a/packaging/macosx/subsurface.sh
+++ b/packaging/macosx/subsurface.sh
@@ -2,7 +2,7 @@

 ! test "$GTK_DEBUG_LAUNCHER" || set -x

-if test "x$GTK_DEBUG_GDB" != x; then
+if test "$GTK_DEBUG_GDB"; then
 	EXEC="gdb --args"
 else
 	EXEC=exec


Cheers,

-- 
Cristian


More information about the subsurface mailing list