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
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
@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}
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 ();
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]);
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.