[PATCH 1/3] genmakefile.sh: Change echo to printf for better portability & control

Alan Coopersmith alan.coopersmith at oracle.com
Tue Jul 2 19:35:14 PDT 2013


Solaris has too many echoes, some which support "-n" to not print newlines,
others which simply treat it as another item to echo to stdout.

The printf command is more portable, allows us better control over newline
insertion and quoting, and easier to read indicators for tabs.

After this change, when run on Solaris, the Makefile.cursors produced in
the redglass & whiteglass directories by genmakefile.sh are identical to
the versions currently checked into git.

Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 genmakefile.sh |   25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/genmakefile.sh b/genmakefile.sh
index 34d0b8b..23b25a7 100755
--- a/genmakefile.sh
+++ b/genmakefile.sh
@@ -4,26 +4,27 @@
 
 test "x$1" = "x" || . "$1"
 
-echo "# this is a generated file -- do not edit."
-echo 
-echo "CURSORFILES = ${CURSORS}"
-echo "CLEANFILES = \$(CURSORFILES)"
-echo "cursor_DATA = \$(CURSORFILES)"
-echo
+printf '# this is a generated file -- do not edit.\n'
+printf '\n'
+printf 'CURSORFILES = %s\n' "${CURSORS}"
+printf 'CLEANFILES = $(CURSORFILES)\n'
+printf 'cursor_DATA = $(CURSORFILES)\n'
+printf '\n'
 
 for i in $CURSORS; do
-	echo -n "${i}:"
+	printf '%s:' "${i}"
 	for png in $(cut -d" " -f4 ${i}.cfg); do
 		EXTRA_DIST="${EXTRA_DIST} ${png}"
-		echo -n " \$(srcdir)/${png}"
+		printf ' $(srcdir)/%s' "${png}"
 	done
-	echo
-	echo "	\$(XCURSORGEN) -p \$(srcdir) \$(srcdir)/${i}.cfg ${i}"
-	echo
+	printf '\n'
+	printf '\t$(XCURSORGEN) -p $(srcdir) $(srcdir)/%s.cfg %s\n' \
+	    "${i}" "${i}"
+	printf '\n'
 	EXTRA_DIST="${EXTRA_DIST} ${i}.cfg ${i}.xcf"
 done
 
 test "x$DIST" = "x" || EXTRA_DIST="${EXTRA_DIST} ${DIST}"
 
 # the lack of space is intentional.
-echo "EXTRA_DIST =${EXTRA_DIST}"
+printf 'EXTRA_DIST =%s\n' "${EXTRA_DIST}"
-- 
1.7.9.2



More information about the xorg-devel mailing list