Subject: [Patch] Replace "echo -n" with printf

From: Lars Wendler <[email-masked]>
Date: Fri, 7 Nov 2014 16:51:42 +0100

Package: x2goclient
Version: git master

Hi,

at Gentoo latest version of the dash shell doesn't support "echo -n"
anymore[1]. The result is that x2gpath returns every path with a
prefixed "-n " when dash is used as /bin/sh.
Accoring to "man p1 echo" section "APPLICATION USAGE" applications
should not rely on "echo -n" but use printf instead.
The attached patch does exactly that.

Kind regards
Lars

[1] https://bugs.gentoo.org/528452

-- 
Lars Wendler
Gentoo package maintainer
GPG: 4DD8 C47C CDFA 5295 E1A6 3FC8 F696 74AB 981C A6FC
From a4766ccfe06b7bb7c445a9fd2efd0f8e2d55bbba Mon Sep 17 00:00:00 2001
From: Lars Wendler <[email-masked]>
Date: Fri, 7 Nov 2014 13:35:08 +0100
Subject: [PATCH] "echo -n" cannot be expected to work with every POSIX shell.
 See "man 1p echo" section APPLICATION USAGE. This patch replaces "echo -n"
 with "printf '%s'".

Signed-off-by: Lars Wendler <[email-masked]>
---
 rpm/x2goserver.init              |  4 ++--
 x2goserver-xsession/etc/Xsession |  4 ++--
 x2goserver/bin/x2gopath          | 12 ++++++------
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/rpm/x2goserver.init b/rpm/x2goserver.init
index a2e6619..842b17f 100644
--- a/rpm/x2goserver.init
+++ b/rpm/x2goserver.init
@@ -35,7 +35,7 @@ start() {
 		mkdir $XSOCKDIR
 		chmod 1777 $XSOCKDIR
 	fi
-	echo -n $"Starting $prog: "
+	printf '%s' $"Starting $prog: "
 	daemon $exec $OPTS
 	retval=$?
 	echo
@@ -43,7 +43,7 @@ start() {
 }
 
 stop() {
-	echo -n $"Stopping $prog: "
+	printf '%s' $"Stopping $prog: "
 	killproc $exec
 	retval=$?
 	echo
diff --git a/x2goserver-xsession/etc/Xsession b/x2goserver-xsession/etc/Xsession
index 3b85b9e..e922dfc 100755
--- a/x2goserver-xsession/etc/Xsession
+++ b/x2goserver-xsession/etc/Xsession
@@ -26,9 +26,9 @@ message_nonl () {
 	# pretty-print messages of arbitrary length (no trailing newline); use
 	# xmessage if it is available and $DISPLAY is set
 	MESSAGE="$PROGNAME: $*"
-	echo -n "$MESSAGE" | fold -s -w ${COLUMNS:-80} >&2;
+	printf '%s' "$MESSAGE" | fold -s -w ${COLUMNS:-80} >&2;
 	if [ -n "$DISPLAY" ] && which xmessage 1> /dev/null 2>&1; then
-		echo -n "$MESSAGE" | fold -s -w ${COLUMNS:-80} | xmessage -center -file -
+		printf '%s' "$MESSAGE" | fold -s -w ${COLUMNS:-80} | xmessage -center -file -
 	fi
 }
 
diff --git a/x2goserver/bin/x2gopath b/x2goserver/bin/x2gopath
index 8fb36a8..dc6b1ba 100755
--- a/x2goserver/bin/x2gopath
+++ b/x2goserver/bin/x2gopath
@@ -31,12 +31,12 @@ base=$(readlink -f "$base/..");
 
 # The following section is subject to substitution by distro packaging tools.
 case "$1" in
-	"base") echo -n "$base";;
-	"lib") echo -n "$base/lib/x2go";;
-	"libexec") echo -n "$base/lib/x2go";;
-	"share") echo -n "$base/share/x2go";;
-	"nx-x11") echo -n "$base/lib/nx/X11";;
-	"xinerama") echo -n "$base/lib/nx/X11/Xinerama";;
+	"base") printf '%s' "$base";;
+	"lib") printf '%s' "$base/lib/x2go";;
+	"libexec") printf '%s' "$base/lib/x2go";;
+	"share") printf '%s' "$base/share/x2go";;
+	"nx-x11") printf '%s' "$base/lib/nx/X11";;
+	"xinerama") printf '%s' "$base/lib/nx/X11/Xinerama";;
 	*) exit 1;;
 esac;
 
-- 
2.1.3

---

From: Mike Gabriel <[email-masked]>
Date: Fri, 07 Nov 2014 20:56:02 +0000

Control: reassign -1 x2goserver
Control: tag -1 patch
Control: severity -1 important

Hi Lars,

> [1] https://bugs.gentoo.org/528452

I will apply your patch ASAP. You made a valid point!

Mike

-- 

DAS-NETZWERKTEAM
mike gabriel, herweg 7, 24357 fleckeby
fon: +49 (1520) 1976 148

GnuPG Key ID 0x25771B31
mail: [email-masked], http://das-netzwerkteam.de

freeBusy:
https://mail.das-netzwerkteam.de/freebusy/m.gabriel%40das-netzwerkteam.de.xfb