[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Should "df --portability" allow thousands separators?
From: |
Paul Eggert |
Subject: |
Re: Should "df --portability" allow thousands separators? |
Date: |
Tue, 27 Feb 2007 09:50:52 -0800 |
User-agent: |
Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux) |
"Peter D." <address@hidden> writes:
> When an inconsistent set of environment variables and command
> line options is given then sending a polite informative version
> of "programming error" to standard error is useful. However,
> sending most sensible output to standard out will cause the
> least grief.
I also would prefer avoiding a diagnostic if possible. Also, it
seems confusing to pay attention to part of an environment variable,
but ignore the rest.
How about using the following rule instead?
If -P is used, ignore the DF_BLOCK_SIZE, BLOCK_SIZE, and BLOCKSIZE
environment variables.
This is easier to document and understand (at least for me....).
Here's a proposed patch to do that.
A more-radical option would be to also ignore POSIXLY_CORRECT if -P is
specified: i.e., the default block size is 512 if -P is used. This
would be more "in the spirit of POSIX" but would be less compatible
with existing GNU practice.
[ChangeLog]
* NEWS: With -P, the default block size and output format is not
affected by DF_BLOCK_SIZE, BLOCK_SIZE, or BLOCKSIZE.
* src/df.c (main): Implement this.
[doc/ChangeLog]
* coreutils.texi (df invocation): With -P, the default block size
and output format is not affected by DF_BLOCK_SIZE, BLOCK_SIZE, or
BLOCKSIZE.
diff --git a/NEWS b/NEWS
index 08724b7..65a7d52 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,11 @@ GNU coreutils NEWS -*-
outline -*-
* Noteworthy changes in release 6.8+ (????-??-??) [not-unstable]
+** Bug fixes
+
+ The default block size and output format for df -P are now unaffected by
+ the DF_BLOCK_SIZE, BLOCK_SIZE, and BLOCKSIZE environment variables. It
+ is still affected by POSIXLY_CORRECT, though.
* Noteworthy changes in release 6.8 (2007-02-24) [not-unstable]
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 99412e4..b313afd 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -9481,6 +9481,13 @@ some network mounts), the columns are misaligned.
@item
The labels in the header output line are changed to conform to @acronym{POSIX}.
+
address@hidden
+The default block size and output format are unaffected by the
address@hidden, @env{BLOCK_SIZE} and @env{BLOCKSIZE} environment
+variables. However, the default block size is still affected by
address@hidden: it is 512 if @env{POSIXLY_CORRECT} is set, 1024
+otherwise. @xref{Block size}.
@end enumerate
@optSi
diff --git a/src/df.c b/src/df.c
index 8bc4a84..609787e 100644
--- a/src/df.c
+++ b/src/df.c
@@ -796,10 +796,7 @@ main (int argc, char **argv)
inode_format = false;
show_all_fs = false;
show_listed_fs = false;
-
- human_output_opts = human_options (getenv ("DF_BLOCK_SIZE"), false,
- &output_block_size);
-
+ human_output_opts = -1;
print_type = false;
file_systems_processed = false;
posix_format = false;
@@ -876,6 +873,18 @@ main (int argc, char **argv)
}
}
+ if (human_output_opts == -1)
+ {
+ if (posix_format)
+ {
+ human_output_opts = 0;
+ output_block_size = (getenv ("POSIXLY_CORRECT") ? 512 : 1024);
+ }
+ else
+ human_output_opts = human_options (getenv ("DF_BLOCK_SIZE"), false,
+ &output_block_size);
+ }
+
/* Fail if the same file system type was both selected and excluded. */
{
bool match = false;
M ChangeLog
M NEWS
M doc/ChangeLog
M doc/coreutils.texi
M src/df.c
Committed as 8593bc37abba49958a143aea2ed01bd9f01e7a2a
- Should "df --portability" allow thousands separators?, Peter D., 2007/02/24
- Re: Should "df --portability" allow thousands separators?, Paul Eggert, 2007/02/25
- Re: Should "df --portability" allow thousands separators?, Peter D., 2007/02/26
- Re: Should "df --portability" allow thousands separators?, Paul Eggert, 2007/02/26
- Re: Should "df --portability" allow thousands separators?, Peter D., 2007/02/26
- Re: Should "df --portability" allow thousands separators?, Jim Meyering, 2007/02/26
- Re: Should "df --portability" allow thousands separators?, Peter D., 2007/02/26
- Re: Should "df --portability" allow thousands separators?,
Paul Eggert <=
- Re: Should "df --portability" allow thousands separators?, Jim Meyering, 2007/02/27
- Re: Should "df --portability" allow thousands separators?, Peter D., 2007/02/28
- Re: Should "df --portability" allow thousands separators?, Paul Eggert, 2007/02/28