OK, thanks, here's a proposed patch to implement BSD-like behavior for coreutils and BLOCKSIZE. (The hard part is the documentation :-).
2004-02-25 Paul Eggert <[EMAIL PROTECTED]> * NEWS: New environment var BLOCKSIZE. * doc/coreutils.texi (Block size): Document it. * lib/human.c (humblock): Support it. * tests/envvar-check: Test for it. Factor the code to simplify it. Index: NEWS =================================================================== RCS file: /home/meyering/coreutils/cu/NEWS,v retrieving revision 1.178 diff -p -u -r1.178 NEWS --- NEWS 21 Feb 2004 09:26:56 -0000 1.178 +++ NEWS 25 Feb 2004 18:14:33 -0000 @@ -1,6 +1,15 @@ GNU coreutils NEWS -*- outline -*- * Major changes in release 5.2.1 (2004-02-19) [stable] +** New features + + 'df', 'du', and 'ls' now take the default block size from the + BLOCKSIZE environment variable if the BLOCK_SIZE, DF_BLOCK_SIZE, + DU_BLOCK_SIZE, and LS_BLOCK_SIZE environment variables are not set. + Unlike the other variables, though, BLOCKSIZE does not affect + values like 'ls -l' sizes that are normally displayed as bytes. + This new behavior is for compatibility with BSD. + ** Bug fixes `expr' now conforms to POSIX better: Index: doc/coreutils.texi =================================================================== RCS file: /home/meyering/coreutils/cu/doc/coreutils.texi,v retrieving revision 1.161 diff -p -u -r1.161 coreutils.texi --- doc/coreutils.texi 22 Feb 2004 15:44:32 -0000 1.161 +++ doc/coreutils.texi 25 Feb 2004 17:55:02 -0000 @@ -744,6 +744,7 @@ used for display is independent of any f Fractional block counts are rounded up to the nearest integer. @opindex [EMAIL PROTECTED] [EMAIL PROTECTED] BLOCKSIZE @vindex BLOCK_SIZE @vindex DF_BLOCK_SIZE @vindex DU_BLOCK_SIZE @@ -764,9 +765,18 @@ Similarly, @env{DU_BLOCK_SIZE} specifies This specifies the default block size for all three commands, if the above command-specific environment variables are not set. [EMAIL PROTECTED] BLOCKSIZE +This specifies the default block size for all values that are normally +printed as blocks, if neither @env{BLOCK_SIZE} nor the above +command-specific environment variables are set. Unlike the other +environment variables, @env{BLOCKSIZE} does not affect values that are +normally printed as byte counts, e.g., the file sizes contained in [EMAIL PROTECTED] -l} output. + @item POSIXLY_CORRECT -If neither the @[EMAIL PROTECTED] nor the @env{BLOCK_SIZE} -variables are set, but this variable is set, the block size defaults to 512. +If neither @[EMAIL PROTECTED], nor @env{BLOCK_SIZE}, nor [EMAIL PROTECTED] is set, but this variable is set, the block size +defaults to 512. @end table Index: lib/human.c =================================================================== RCS file: /home/meyering/coreutils/cu/lib/human.c,v retrieving revision 1.24 diff -p -u -r1.24 human.c --- lib/human.c 15 Oct 2003 07:26:01 -0000 1.24 +++ lib/human.c 23 Feb 2004 18:58:35 -0000 @@ -428,7 +428,9 @@ humblock (char const *spec, uintmax_t *b int i; int opts = 0; - if (! spec && ! (spec = getenv ("BLOCK_SIZE"))) + if (! spec + && ! (spec = getenv ("BLOCK_SIZE")) + && ! (spec = getenv ("BLOCKSIZE"))) *block_size = default_block_size (); else { Index: tests/envvar-check =================================================================== RCS file: /home/meyering/coreutils/cu/tests/envvar-check,v retrieving revision 1.4 diff -p -u -r1.4 envvar-check --- tests/envvar-check 20 Feb 2003 17:59:37 -0000 1.4 +++ tests/envvar-check 25 Feb 2004 18:04:53 -0000 @@ -4,50 +4,24 @@ else as_unset=false fi -# FIXME-someday: The following is begging to be factored, ... - -$as_unset VERSION_CONTROL SIMPLE_BACKUP_SUFFIX -$as_unset BLOCK_SIZE DU_BLOCK_SIZE DF_BLOCK_SIZE LS_BLOCK_SIZE - -if test "${VERSION_CONTROL+set}" = set; then - echo "$0: the VERSION_CONTROL envvar is set --" \ - ' unset it and rerun this test' >&2 - envvar_check_fail=1 -fi - -if test "${SIMPLE_BACKUP_SUFFIX+set}" = set; then - echo "$0: the SIMPLE_BACKUP_SUFFIX envvar is set --" \ - ' unset it and rerun this test' >&2 - >&2 - envvar_check_fail=1 -fi - -if test "${BLOCK_SIZE+set}" = set; then - echo "$0: the BLOCK_SIZE envvar is set --" \ - ' unset it and rerun this test' >&2 - >&2 - envvar_check_fail=1 -fi - -if test "${DU_BLOCK_SIZE+set}" = set; then - echo "$0: the DU_BLOCK_SIZE envvar is set --" \ - ' unset it and rerun this test' >&2 - >&2 - envvar_check_fail=1 -fi - -if test "${DF_BLOCK_SIZE+set}" = set; then - echo "$0: the DF_BLOCK_SIZE envvar is set --" \ - ' unset it and rerun this test' >&2 - >&2 - envvar_check_fail=1 -fi - -if test "${LS_BLOCK_SIZE+set}" = set; then - echo "$0: the LS_BLOCK_SIZE envvar is set --" \ - ' unset it and rerun this test' >&2 - >&2 - envvar_check_fail=1 -fi +envvar_check_failed=0 +vars=' + BLOCKSIZE + BLOCK_SIZE + DF_BLOCK_SIZE + DU_BLOCK_SIZE + LS_BLOCK_SIZE + SIMPLE_BACKUP_SUFFIX + VERSION_CONTROL +' +for var in $vars +do + $as_unset $var + if eval test \"\${$var+set}\" = set; then + echo "$0: the $var environment variable is set --" \ + ' unset it and rerun this test' >&2 + envvar_check_failed=1 + fi +done test "$envvar_check_fail" = 1 && exit 1 _______________________________________________ Bug-coreutils mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/bug-coreutils