Re: [coreutils] [PATCH] tests: fix a printf portability issue
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.
Re: [coreutils] [PATCH] tests: fix a printf portability issue
On 19/09/10 07:50, Jim Meyering wrote: 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. I'll change as you suggest (and also in the join-i18n test). Note I left the double quotes (and octal escapes) because that's what vim highlights. vim's shell highlighting is woeful anyway, especially if you don't change the default like this in your ~/.vimrc let g:is_posix = 1 I should fix up vim rather than tweaking scripts to accommodate it. cheers, Pádraig.
[coreutils] [PATCH] tests: fix a printf portability issue
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 # Check that \0 and \t intermix. printf \0\ta\n | sort -s -k2b,2 --debug | tr -d '\0'