Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/sh Use printf, rather than echo (via echo redefined as a...



details:   https://anonhg.NetBSD.org/src/rev/22758d16e20a
branches:  trunk
changeset: 446437:22758d16e20a
user:      kre <kre%NetBSD.org@localhost>
date:      Wed Dec 05 09:20:18 2018 +0000

description:
Use printf, rather than echo (via echo redefined as a function that
uses printf for simplicity).

This script runs using the build host's shell, and echo, and so must
deal with all of the absurdity that different versions of echo dumb
upon us.

This is the underlying cause of the linux build failure that gson@ reported.

diffstat:

 bin/sh/mkinit.sh |  23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)

diffs (38 lines):

diff -r 15090b1417d8 -r 22758d16e20a bin/sh/mkinit.sh
--- a/bin/sh/mkinit.sh  Wed Dec 05 06:51:16 2018 +0000
+++ b/bin/sh/mkinit.sh  Wed Dec 05 09:20:18 2018 +0000
@@ -1,5 +1,5 @@
 #! /bin/sh
-#      $NetBSD: mkinit.sh,v 1.9 2018/10/18 04:24:43 kre Exp $
+#      $NetBSD: mkinit.sh,v 1.10 2018/12/05 09:20:18 kre Exp $
 
 # Copyright (c) 2003 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -30,6 +30,27 @@
 
 srcs="$*"
 
+# use of echo in this script is broken
+
+# some echo versions will expand \n in the args, which breaks C
+# Note: this script is a HOST_PROG ... it must run in the
+# build host's environment, with its shell.
+
+# Fortunately, use of echo here is also trivially simplistic,
+# we can easily replace all uses with ...
+
+echo()
+{
+       printf '%s\n' "$1"
+}
+
+# CAUTION: for anyone modifying this script.... use printf
+# rather than echo to output anything at all... then
+# you will avoid being bitten by the simplicity of this function.
+# This was done this way rather than wholesale replacement
+# to avoid unnecessary code churn.
+
+
 nl='
 '
 openparen='('



Home | Main Index | Thread Index | Old Index