]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
pwd: assume -L mode by default, as per POSIX
authorPádraig Brady <P@draigBrady.com>
Mon, 30 Jun 2014 09:15:26 +0000 (10:15 +0100)
committerPádraig Brady <P@draigBrady.com>
Mon, 30 Jun 2014 09:27:48 +0000 (10:27 +0100)
* 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.

NEWS
doc/coreutils.texi
src/pwd.c
tests/misc/pwd-option.sh

diff --git a/NEWS b/NEWS
index 4e90b793b891bc1a6a18a77f91a7ce6d5b771478..a72d3bd4a994a1d9023e9501cc9f09ee4e2ef86b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -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
index 96220c3508b78baad4b59f0cc1c431526b490e9c..d0c8ea8d587c0c24be655d46b8bb67bab49bde96 100644 (file)
@@ -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}
 
index 4993dfb9dd037146bc71b397fd18b8b6ae44c0bc..af9ef50a1bc44bc8f0a2e69974fcb0506b2dc873 100644 (file)
--- a/src/pwd.c
+++ b/src/pwd.c
@@ -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]);
index afb94877aef75adb497fe8fd6f5770e69b25a5ac..983726b66a707f2f8333bc2c2d3a6ae036be3693 100755 (executable)
@@ -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.