diff mbox

[libgo,build] Avoid echo -n in gotest

Message ID yddlizo4vt8.fsf@manam.CeBiTec.Uni-Bielefeld.DE
State New
Headers show

Commit Message

Rainer Orth April 5, 2011, 2:28 p.m. UTC
Inspecting the Solaris 8 libgo.sum file, I was reminded that echo -n
isn't portable.  The autoconf manual agrees and suggests printf as a
replacement.  The following patch implements this.

Bootstrapped on i386-pc-solaris2.8 with gas.

	Rainer


2011-04-05  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	* testsuite/gotest: Use printf instead of echo -n.

Comments

Andreas Schwab April 5, 2011, 2:37 p.m. UTC | #1
Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> writes:

> diff --git a/libgo/testsuite/gotest b/libgo/testsuite/gotest
> --- a/libgo/testsuite/gotest
> +++ b/libgo/testsuite/gotest
> @@ -231,7 +231,7 @@ mkdir _test
>  
>  case "x$gofiles" in
>  x)
> -	gofiles=$(echo -n $(ls *_test.go 2>/dev/null))
> +	gofiles=$(printf "%s" "$(ls *_test.go 2>/dev/null)")

There is no reason to use "echo -n" in the first place, since command
substitution strips trailing newlines.  But the printf replacement keeps
internal newlines, unlike the original line.  If that is ok then this is
a useless use of printf, since you can just assign the output of the
nested command directly.

Andreas.
diff mbox

Patch

diff --git a/libgo/testsuite/gotest b/libgo/testsuite/gotest
--- a/libgo/testsuite/gotest
+++ b/libgo/testsuite/gotest
@@ -231,7 +231,7 @@  mkdir _test
 
 case "x$gofiles" in
 x)
-	gofiles=$(echo -n $(ls *_test.go 2>/dev/null))
+	gofiles=$(printf "%s" "$(ls *_test.go 2>/dev/null)")
 esac
 
 case "x$gofiles" in
@@ -250,7 +250,7 @@  GC="$holdGC"
 
 case "x$pkgfiles" in
 x)
-	pkgbasefiles=$(echo -n $(ls *.go | grep -v _test.go 2>/dev/null))
+	pkgbasefiles=$(printf "%s" "$(ls *.go | grep -v _test.go 2>/dev/null)")
 	;;
 *)
 	for f in $pkgfiles; do