Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

cwd unintentionally changed



Hi *,

I got myself into a situation where zsh changed my working directory to
"/" without further notice. Unfortunately, the next command I issued was
"sudo rm -rf *", which did not end well with cwd being "/" :-(

My colleagues and me started to track down the bug. Our efforts are
documented here:
https://github.com/grml/grml-etc-core/issues/76

(We initially though it was a bug with grml zsh config.)

A minimal example that triggers the bug looks like this:

$ mkdir /tmp/tmp.0HnyRZ1iXv/
$ cd /tmp/tmp.0HnyRZ1iXv/
$ mkdir a
$ sudo zsh -f -c 'mount -t tmpfs tmpfs a; cd a; touch x; ls; umount
--lazy ../a; ls; foo=.; echo ${foo:a}; ls; realpath .; echo $PWD;'

It will output the following:
x                      # content of directory a (expected)
x                      # content of directory a (expected)
/                      # NOT expected
bin dev ...            # content of / (NOT expected)
/                      # NOT expected
/tmp/tmp.0HnyRZ1iXv/a  # expected

cwd silently changed to "/" while pwd does not know about this.

This looks like a very specific use case, but a change [0] about how
vcs_info gets the base directory for the repository also triggers this
bug. In my case when using Gnome which automatically mounts and unmounts
external drives (with the --lazy option).

After ending up in the source code for zgetcwd() and zgetdir() we
decided to hand the issue over to you :-)

Regards,
Yannic

[0]
https://github.com/zsh-users/zsh/commit/faa07d064bb2bd9cd9892a255a4b63811242b9fb
-- 
Yannic Schröder, M.Sc.

Technische Universität Braunschweig
Institut für Betriebssysteme und Rechnerverbund
Mühlenpfordtstr. 23
38106 Braunschweig

Fon: +49 (531) 391 - 3249
Fax: +49 (531) 391 - 5936
E-Mail: schroeder@xxxxxxxxxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author