mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-04 10:41:11 +02:00
zsh-workers/8084
This commit is contained in:
parent
4908fb3158
commit
b015f25ec9
2 changed files with 28 additions and 3 deletions
|
@ -682,7 +682,12 @@ item(tt(pwd) [ tt(-rLP) ])(
|
||||||
Print the absolute pathname of the current working directory.
|
Print the absolute pathname of the current working directory.
|
||||||
If the tt(-r) or the tt(-P) flag is specified, or the tt(CHASE_LINKS)
|
If the tt(-r) or the tt(-P) flag is specified, or the tt(CHASE_LINKS)
|
||||||
option is set and the tt(-L) flag is not given, the printed path will not
|
option is set and the tt(-L) flag is not given, the printed path will not
|
||||||
contain symbolic links.
|
contain symbolic links. Otherwise, the shell will print the stored
|
||||||
|
directory, i.e. the value to which tt($PWD) was last set. In this case, it
|
||||||
|
will check that the current tt($PWD) is still valid; if it is, or if it is
|
||||||
|
unable to find a valid path because the current directory no longer exists,
|
||||||
|
it will print that, and if it is not, it will print the full path without
|
||||||
|
symbolic links and update tt($PWD) accordingly.
|
||||||
)
|
)
|
||||||
alias(r)(fc -e -)
|
alias(r)(fc -e -)
|
||||||
findex(read)
|
findex(read)
|
||||||
|
|
|
@ -572,8 +572,28 @@ bin_pwd(char *name, char **argv, char *ops, int func)
|
||||||
if (ops['r'] || ops['P'] || (isset(CHASELINKS) && !ops['L']))
|
if (ops['r'] || ops['P'] || (isset(CHASELINKS) && !ops['L']))
|
||||||
printf("%s\n", zgetcwd());
|
printf("%s\n", zgetcwd());
|
||||||
else {
|
else {
|
||||||
zputs(pwd, stdout);
|
struct stat stdot, stpwd;
|
||||||
putchar('\n');
|
char *tmppwd;
|
||||||
|
/*
|
||||||
|
* We could print nothing and return status 1 if we can't
|
||||||
|
* stat ., but that's incompatible with both ksh and what
|
||||||
|
* we used to do.
|
||||||
|
*/
|
||||||
|
if (stat(".", &stdot) < 0 ||
|
||||||
|
stat(pwd, &stpwd) >= 0 && stpwd.st_ino == stdot.st_ino) {
|
||||||
|
zputs(pwd, stdout);
|
||||||
|
putchar('\n');
|
||||||
|
} else {
|
||||||
|
/*
|
||||||
|
* The directory has changed without us noticing it. We
|
||||||
|
* need to change pwd, since directory changing commands
|
||||||
|
* are liable to fail otherwise.
|
||||||
|
*/
|
||||||
|
zsfree(pwd);
|
||||||
|
printf("%s\n", tmppwd = zgetcwd());
|
||||||
|
pwd = metafy(tmppwd, -1, META_DUP);
|
||||||
|
set_pwd_env();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue