[kupfer] bin: Make script executables compatible with posix shell



commit 3c2a331e00c91f49e45efbf3b11941c55c4ef82b
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Mon Feb 28 23:07:27 2011 +0100

    bin: Make script executables compatible with posix shell
    
    Avoid a few bashisms and use /bin/sh

 bin/kupfer-exec.in |    4 ++--
 bin/kupfer.in      |   14 +++++++++-----
 2 files changed, 11 insertions(+), 7 deletions(-)
---
diff --git a/bin/kupfer-exec.in b/bin/kupfer-exec.in
index 3540313..d560241 100755
--- a/bin/kupfer-exec.in
+++ b/bin/kupfer-exec.in
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 
 # This is a helper program to execute saved command files,
 # by sending them to a running instance of Kupfer.
@@ -24,7 +24,7 @@ do
 	then
 		# NOTE: If you change this string, you have to change
 		# it inside kupfer/version.py as well.
-		zenity --info --text $"Could not find running Kupfer" &
+		zenity --info --text "$(gettext 'Could not find running Kupfer')" &
 		exit 1
 	fi
 	shift
diff --git a/bin/kupfer.in b/bin/kupfer.in
index 03daecc..d76f7bc 100755
--- a/bin/kupfer.in
+++ b/bin/kupfer.in
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 # kupfer      A convenient command and access tool
 #
 # Copyright 2007--2010 Ulrik Sverdrup <ulrik sverdrup gmail com>
@@ -19,10 +19,14 @@
 # This script invokes kupfer by calling an already running instance, or
 # starting a new if none is found running.
 
+_hasprefix () {
+	test "x${1#$2}" != "x$1"
+}
+
 PYTHON="@PYTHON@"
 PYTHONDIR="@PYTHONDIR@"
-test ${PYTHON:0:1} = "@" && PYTHON=python2.6
-test ${PYTHONDIR:0:1} = "@" && PYTHONDIR=$(dirname $(readlink -f -- $0))/..
+_hasprefix "$PYTHON" "@"  && PYTHON=python2.6
+_hasprefix "$PYTHONDIR" "@" && PYTHONDIR=$(dirname $(readlink -f -- $0))/..
 
 SERVICE="se.kaizer.kupfer"
 OBJ="/interface"
@@ -36,7 +40,7 @@ then
 fi
 
 # If there are any options, like "--help", we run Kupfer directly
-test "x${1:0:2}" = "x--"
+_hasprefix "$1" "--"
 KUPFER_HAS_OPTIONS=$?
 
 test $KUPFER_HAS_OPTIONS != 0 && dbus-send --type=method_call --print-reply \
@@ -59,7 +63,7 @@ _realpaths () {
 			shift
 			continue
 		fi
-		echo -ne "$LINK\0"
+		printf "%s\0" "$LINK"
 		shift
 	done
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]