Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/make/unit-tests Some systems (eg. MirBSD) use a ksh, ...



details:   https://anonhg.NetBSD.org/src/rev/4ba9bd6120a5
branches:  trunk
changeset: 765816:4ba9bd6120a5
user:      sjg <sjg%NetBSD.org@localhost>
date:      Tue Jun 07 00:10:20 2011 +0000

description:
Some systems (eg. MirBSD) use a ksh, with an echo which cannot
be used for things containing \x: etc.
Check for print or printf as builtin and use if available.
Note that a builtin will fail, if make decides a shell is not needed.

diffstat:

 usr.bin/make/unit-tests/modts |  27 +++++++++++++++++++--------
 1 files changed, 19 insertions(+), 8 deletions(-)

diffs (41 lines):

diff -r d75c961f5e18 -r 4ba9bd6120a5 usr.bin/make/unit-tests/modts
--- a/usr.bin/make/unit-tests/modts     Mon Jun 06 22:04:34 2011 +0000
+++ b/usr.bin/make/unit-tests/modts     Tue Jun 07 00:10:20 2011 +0000
@@ -9,6 +9,17 @@
 
 all:   mod-ts
 
+# Use print or printf iff they are builtin.
+# XXX note that this causes problems, when make decides 
+# there is no need to use a shell, so avoid where possible.
+.if ${type print 2> /dev/null || echo:L:sh:Mbuiltin} != ""
+PRINT= print -r --
+.elif ${type printf 2> /dev/null || echo:L:sh:Mbuiltin} != ""
+PRINT= printf '%s\n'
+.else
+PRINT= echo
+.endif
+
 mod-ts:
        @echo 'LIST="${LIST}"'
        @echo 'LIST:ts,="${LIST:ts,}"'
@@ -22,11 +33,11 @@
        @echo 'LIST:S/two/2/:ts="${LIST:S/two/2/:ts}"'
        @echo 'LIST:ts/:S/two/2/="${LIST:ts/:S/two/2/}"'
        @echo "Pretend the '/' in '/n' etc. below are back-slashes."
-       @echo 'LIST:ts/n="${LIST:ts\n}"'
-       @echo 'LIST:ts/t="${LIST:ts\t}"'
-       @echo 'LIST:ts/012:tu="${LIST:ts\012:tu}"'
-       @echo 'LIST:tx="${LIST:tx}"'
-       @echo 'LIST:ts/x:tu="${LIST:ts\x:tu}"'
-       @echo 'FU_$@="${FU_${@:ts}:ts}"'
-       @echo 'FU_$@:ts:T="${FU_${@:ts}:ts:T}" == cool?'
-       @echo 'B.$${AAA:ts}="${B.${AAA:ts}}" == Baaa?'
+       @${PRINT} 'LIST:ts/n="${LIST:ts\n}"'
+       @${PRINT} 'LIST:ts/t="${LIST:ts\t}"'
+       @${PRINT} 'LIST:ts/012:tu="${LIST:ts\012:tu}"'
+       @${PRINT} 'LIST:tx="${LIST:tx}"'
+       @${PRINT} 'LIST:ts/x:tu="${LIST:ts\x:tu}"'
+       @${PRINT} 'FU_$@="${FU_${@:ts}:ts}"'
+       @${PRINT} 'FU_$@:ts:T="${FU_${@:ts}:ts:T}" == cool?'
+       @${PRINT} 'B.$${AAA:ts}="${B.${AAA:ts}}" == Baaa?'



Home | Main Index | Thread Index | Old Index