[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [coreutils] [PATCH] tests: fix a printf portability issue
From: |
Jim Meyering |
Subject: |
Re: [coreutils] [PATCH] tests: fix a printf portability issue |
Date: |
Sun, 19 Sep 2010 08:50:00 +0200 |
Pádraig Brady wrote:
> not all printf commands support \xhh
>
> diff --git a/tests/misc/sort-debug-keys b/tests/misc/sort-debug-keys
> index 57a52a6..4e8beff 100755
> --- a/tests/misc/sort-debug-keys
> +++ b/tests/misc/sort-debug-keys
> @@ -275,7 +275,7 @@ printf "2.,,3\n2.4\n" | sort -s -k1n --debug
> printf "2,,3\n2.4\n" | sort -s -k1n --debug
>
> # -z means we convert \0 to \n
> -printf "1a\x002b\x00" | sort -s -n -z --debug
> +printf "1a\0002b\000" | sort -s -n -z --debug
That would accommodate an inferior printf builtin function,
with the implication that all printf uses should do the same.
It may be hard or at least tedious to audit existing uses --
then it'd be good (but more work) to enforce the no-\xHH policy.
Since this is the coreutils, we have the option of a more sustainable
policy: use "env" to ensure the test runs the printf binary that we've
just built in this package:
# printf '\xHH' is not portable with some built-ins. FIXME: list an offender
# Use env to force use of the one from coreutils.
env printf '1a\x002b\x00' | sort -s -n -z --debug
That also gives printf more test coverage.
Also, please use single quotes in cases like this,
where nothing is intended to be shell-expanded.