From 76325a660e09d3af503c292ae12c9de2830994e5 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 24 Aug 2016 01:40:43 +0200 Subject: test: Use printf "%b\n" instead of echo for strings with '\' Use of echo with special characters is not portable. On a normal POSIX system, the behavior with backslash escaped strings is implementation-defined. On an XSI-conformant system, they must be interpreted. A way out is the printf command - printf "%b" specifies that the following argument is to be printed with backslash escapes interpreted. Gbp-Dch: ignore --- test/integration/framework | 14 +++++++------- test/integration/test-external-dependency-solver-protocol | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/integration/framework b/test/integration/framework index 3bbb8bc25..3ef8597a8 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -689,7 +689,7 @@ Standards-Version: 3.9.3" if [ "$SECTION" != '' ]; then echo "Section: $SECTION" fi - local BUILDDEPS="$(echo "$DEPENDENCIES" | grep '^Build-')" + local BUILDDEPS="$(printf "%b\n" "$DEPENDENCIES" | grep '^Build-')" test -z "$BUILDDEPS" || echo "$BUILDDEPS" echo " Package: $NAME" @@ -699,9 +699,9 @@ Package: $NAME" else echo "Architecture: any" fi - local DEPS="$(echo "$DEPENDENCIES" | grep -v '^Build-')" + local DEPS="$(printf "%b\n" "$DEPENDENCIES" | grep -v '^Build-')" test -z "$DEPS" || echo "$DEPS" - echo "Description: $DESCRIPTION" + printf "%b\n" "Description: $DESCRIPTION" } > "${BUILDDIR}/debian/control" echo '3.0 (native)' > "${BUILDDIR}/debian/source/format" @@ -911,7 +911,7 @@ Maintainer: Joe Sixpack " test "$arch" = 'none' || echo "Architecture: $arch" echo "Version: $VERSION Filename: pool/main/${NAME}/${NAME}_${VERSION}_${arch}.deb" - test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" + test -z "$DEPENDENCIES" || printf "%b\n" "$DEPENDENCIES" echo "Description: $(printf '%s' "$DESCRIPTION" | head -n 1)" echo "Description-md5: $(printf '%s' "$DESCRIPTION" | md5sum | cut -d' ' -f 1)" echo @@ -946,7 +946,7 @@ Binary: $BINARY Version: $VERSION Maintainer: Joe Sixpack Architecture: $ARCH" >> $FILE - test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> "$FILE" + test -z "$DEPENDENCIES" || printf "%b\n" "$DEPENDENCIES" >> "$FILE" echo "Files: $(echo -n "$DSCFILE" | md5sum | cut -d' ' -f 1) $(echo -n "$DSCFILE" | wc -c) "$DSCFILE" $(echo -n "$TARFILE" | md5sum | cut -d' ' -f 1) $(echo -n "$TARFILE" | wc -c) "$TARFILE" @@ -980,8 +980,8 @@ Installed-Size: 42 Maintainer: Joe Sixpack Version: $VERSION" >> "$FILE" test "$arch" = 'none' || echo "Architecture: $arch" >> "$FILE" - test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> "$FILE" - echo "Description: $DESCRIPTION" >> "$FILE" + test -z "$DEPENDENCIES" || printf "%b\n" "$DEPENDENCIES" >> "$FILE" + printf "%b\n" "Description: $DESCRIPTION" >> "$FILE" echo >> "$FILE" if [ "$(dpkg-query -W --showformat='${Multi-Arch}')" = 'same' ]; then echo -n > "${INFO}/${NAME}:${arch}.list" diff --git a/test/integration/test-external-dependency-solver-protocol b/test/integration/test-external-dependency-solver-protocol index 10b07e896..c86038b1b 100755 --- a/test/integration/test-external-dependency-solver-protocol +++ b/test/integration/test-external-dependency-solver-protocol @@ -152,7 +152,7 @@ testsuccess grep 'ERR_UNSOLVABLE' rootdir/tmp/testfailure.output configarchitecture 'armel' testfailure aptget install --solver apt awesomecoolstuff:i386 -s msgtest 'An invalid EDSP file generates a' 'hard error' -if echo "Request: This is a test\nFoo: bar\n\n" | aptinternalsolver > solver.result 2>&1; then +if printf "%b\n" "Request: This is a test\nFoo: bar\n\n" | aptinternalsolver > solver.result 2>&1; then cat solver.result msgfail else -- cgit v1.2.3