]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
pwd: revert default mode back to -P
authorPádraig Brady <P@draigBrady.com>
Wed, 2 Jul 2014 10:28:05 +0000 (11:28 +0100)
committerPádraig Brady <P@draigBrady.com>
Wed, 2 Jul 2014 18:45:18 +0000 (19:45 +0100)
Revert commit v8.22-131-g3e89d5b as even though POSIX
states that the default mode should be -L,
common practice for stand-alone pwd implementations
is to default to -P.

* src/pwd.c (usage): Retain mention of the default mode of operation.

Suggested by Bob Proulx

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

diff --git a/NEWS b/NEWS
index a72d3bd4a994a1d9023e9501cc9f09ee4e2ef86b..4e90b793b891bc1a6a18a77f91a7ce6d5b771478 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -117,9 +117,6 @@ 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 d0c8ea8d587c0c24be655d46b8bb67bab49bde96..96220c3508b78baad4b59f0cc1c431526b490e9c 100644 (file)
@@ -13738,7 +13738,8 @@ 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{-L} as the default.
+@option{-P} as the default unless the @env{POSIXLY_CORRECT}
+environment variable is set.
 
 @mayConflictWithShellBuiltIn{pwd}
 
index af9ef50a1bc44bc8f0a2e69974fcb0506b2dc873..d126ed7547f70d3555ff590528d8ea1ab2dac8aa 100644 (file)
--- a/src/pwd.c
+++ b/src/pwd.c
@@ -65,7 +65,7 @@ Print the full filename of the current working directory.\n\
       fputs (HELP_OPTION_DESCRIPTION, stdout);
       fputs (VERSION_OPTION_DESCRIPTION, stdout);
       fputs (_("\n\
-If no option is specified, -L is assumed.\n\
+If no option is specified, -P is assumed.\n\
 "), stdout);
       printf (USAGE_BUILTIN_WARNING, PROGRAM_NAME);
       emit_ancillary_info ();
@@ -327,8 +327,10 @@ int
 main (int argc, char **argv)
 {
   char *wd;
-  /* POSIX requires a default of -L.  */
-  bool logical = true;
+  /* POSIX requires a default of -L, but most scripts expect -P.
+     Currently shells default to -L, while stand-alone
+     pwd implementations default to -P.  */
+  bool logical = (getenv ("POSIXLY_CORRECT") != NULL);
 
   initialize_main (&argc, &argv);
   set_program_name (argv[0]);
index 9b4664d34a0b031b57a81418f87cba533be2a017..0eba9429c89b09241ed48cad5712b7ca639b0b72 100755 (executable)
@@ -40,8 +40,11 @@ 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 -L like POSIX and various shells.
+# By default, we use -P unless POSIXLY_CORRECT.
 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.