I have been using "warn/die"-style functions like these for a few years, and they are all based on printf (not echo) for precisely the reasons listed in the log below. I'm surprised that I put an echo-based implementation into the relatively modern "init.sh".
Anyhow, this fixes it: >From c1aff7b4429ec916f47ce115ab11e06938599e99 Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyer...@redhat.com> Date: Tue, 14 Jun 2011 15:37:48 +0200 Subject: [PATCH] tests: use printf, not echo in init.sh's warn_ function * tests/init.sh (warn_): Use printf, not echo. The latter would misbehave when given strings containing a backslash or starting with e.g., -n. --- tests/init.sh | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/tests/init.sh b/tests/init.sh index 4a52626..b1b176c 100644 --- a/tests/init.sh +++ b/tests/init.sh @@ -74,7 +74,7 @@ Exit () { set +e; (exit $1); exit $1; } # the reason for skip/failure to console, rather than to the .log files. : ${stderr_fileno_=2} -warn_ () { echo "$@" 1>&$stderr_fileno_; } +warn_ () { printf '%s\n' "$@" 1>&$stderr_fileno_; } fail_ () { warn_ "$ME_: failed test: $@"; Exit 1; } skip_ () { warn_ "$ME_: skipped test: $@"; Exit 77; } fatal_ () { warn_ "$ME_: hard error: $@"; Exit 99; } -- 1.7.6.rc0.293.g40857