diff options
author | Pádraig Brady <P@draigBrady.com> | 2014-06-30 10:15:26 +0100 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2014-06-30 10:27:48 +0100 |
commit | 3e89d5bb9b34861c17cd23f5efd8323eec4f0bab (patch) | |
tree | eba49317d57cc4c42db3e3bf2aa96102b37de23c | |
parent | acb422bdd1b325285bb46883f02d8fc6402efd14 (diff) | |
download | coreutils-3e89d5bb9b34861c17cd23f5efd8323eec4f0bab.tar.xz |
pwd: assume -L mode by default, as per POSIX
* src/pwd.c (main): Adjust default mode to be "logical"
and independent of the POSIXLY_CORRECT env var.
(usage): Mention the default mode of operation.
* doc/coreutils.texi (pwd invocation): Adjust accordingly.
* tests/misc/pwd-option.sh: Likewise.
* NEWS: Mention the change in behavior.
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | doc/coreutils.texi | 3 | ||||
-rw-r--r-- | src/pwd.c | 7 | ||||
-rwxr-xr-x | tests/misc/pwd-option.sh | 5 |
4 files changed, 10 insertions, 8 deletions
@@ -117,6 +117,9 @@ GNU coreutils NEWS -*- outline -*- will now honor an empty or unknown TERM environment variable, and not output colors even with --colors=always. + pwd now conforms to POSIX and common practice with shell builtins + to assume -L by default, outputting $PWD from the environment if appropriate. + ** Improvements chroot has better --userspec and --group look-ups, with numeric IDs never diff --git a/doc/coreutils.texi b/doc/coreutils.texi index 96220c350..d0c8ea8d5 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -13738,8 +13738,7 @@ will be symbolic links. @cindex symbolic links and @command{pwd} If @option{-L} and @option{-P} are both given, the last one takes precedence. If neither option is given, then this implementation uses -@option{-P} as the default unless the @env{POSIXLY_CORRECT} -environment variable is set. +@option{-L} as the default. @mayConflictWithShellBuiltIn{pwd} @@ -64,6 +64,9 @@ Print the full filename of the current working directory.\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); + fputs (_("\n\ +If no option is specified, -L is assumed.\n\ +"), stdout); printf (USAGE_BUILTIN_WARNING, PROGRAM_NAME); emit_ancillary_info (); } @@ -324,8 +327,8 @@ int main (int argc, char **argv) { char *wd; - /* POSIX requires a default of -L, but most scripts expect -P. */ - bool logical = (getenv ("POSIXLY_CORRECT") != NULL); + /* POSIX requires a default of -L. */ + bool logical = true; initialize_main (&argc, &argv); set_program_name (argv[0]); diff --git a/tests/misc/pwd-option.sh b/tests/misc/pwd-option.sh index afb94877a..983726b66 100755 --- a/tests/misc/pwd-option.sh +++ b/tests/misc/pwd-option.sh @@ -40,11 +40,8 @@ printf %s\\n "$base/a/b" >> exp || fail=1 env -- pwd --physical >> out || fail=1 printf %s\\n "$base/a/b" >> exp || fail=1 -# By default, we use -P unless POSIXLY_CORRECT. +# By default, we use -L like POSIX and various shells. env -- pwd >> out || fail=1 -printf %s\\n "$base/a/b" >> exp || fail=1 - -env -- POSIXLY_CORRECT=1 pwd >> out || fail=1 printf %s\\n "$base/c" >> exp || fail=1 # Make sure we reject bogus values, and silently fall back to -P. |