Module Name: src Committed By: kre Date: Sun Jun 4 20:27:14 UTC 2017
Modified Files: src/bin/sh: cd.c eval.c exec.c exec.h mail.c sh.1 Log Message: Make cd (really) do cd -P, and not just claim that is what it is doing while doing a half-hearted, broken, partial, version of cd -L instead. The latter (as the manual says) is not supported, what's more, it is an abomination, and should never be supported (anywhere.) Fix the doc so that the pretense that we notice when a path given crosses a symlink (and turns on printing of the destination directory) is claimed no more (that used to be true until late Dec 2016, but was changed). Now the print happens if -o cdprint is set, or if an entry from CDPATH that is not "" or "." is used (or if the "cd dest repl" cd cmd variant is used.) Fix CDPATH processing: avoid the magic '%' processing that is used for PATH and MAILPATH from corrupting CDPATH. The % magic (both variants) remains undocumented. Also, don't double the '/' if an entry in PATH or CDPATH ends in '/' (as in CDPATH=":/usr/src/"). A "cd usr.bin" used to do chdir("/usr/src//usr.bin"). No more. This is almost invisible, and relatively harmless, either way.... Also fix a bug where if a plausible destination directory in CDPATH was located, but the chdir() failed (eg: permission denied) and then a later "." or "" CDPATH entry succeeded, "print" mode was turned on. That is: cd /tmp; mkdir bin mkdir -p P/bin; chmod 0 P/bin CDPATH=/tmp/P: cd bin would cd to /tmp/bin (correctly) but print it (incorrectly). Also when in "cd dest replace" mode, if the result of the replacement generates '-' as the path named, as in: cd $PWD - then simply change to '-' (or attempt to, with CDPATH search), rather than having this being equivalent to "cd -") Because of these changes, the pwd command (and $PWD) essentially always acts as pwd -P, even when called as pwd -L (which is still the default.) That is, even more than it did before. Also fixed a (kind of minor) mem management error (CDPATH related) "whosoever shall padvance must stunalloc before repeating" (and the same for MAILPATH). To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/bin/sh/cd.c src/bin/sh/exec.c cvs rdiff -u -r1.140 -r1.141 src/bin/sh/eval.c cvs rdiff -u -r1.24 -r1.25 src/bin/sh/exec.h cvs rdiff -u -r1.16 -r1.17 src/bin/sh/mail.c cvs rdiff -u -r1.146 -r1.147 src/bin/sh/sh.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.