Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: $userdirs empty in non-interactive shells
- X-seq: zsh-workers 42094
- From: Stephane Chazelas <stephane.chazelas@xxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: $userdirs empty in non-interactive shells
- Date: Fri, 8 Dec 2017 12:23:46 +0000
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=eMqOSrw6X8CZE+hLBYUIhEk6deJNd3agcMAOv1izhtM=; b=VP4ve7HznkBf5oKVc9ntFgfnqv4VFui+6LcCqOVMU9A5aAW7Spikl89psXcEjDpwni cXJjYOjijVmBWVOzjEQuz6AaLtZEQtT23ex2wbLGG9T+upX3IrLeb3rD6OmAOvpgYqel KwW1Pvj9GMycJJepJLmABHkNPuXW7wz8LBD2dDWTOr6dDXGXFZaPw4Lfc6TCvHT3C2Ca 75zpohUAA0ps0DTtrtsxJHDEnD2H2Yy2JVnRRyf6aw+ttS3oz8S8BW8DqFrTl3IgNEa1 8h5f9wjQWdQsKsUn1VO/TyfZtDBk1ahtpMlcQxYa8z0gBko6dalp2Wu1jHPX19TIXNyA pkPg==
- In-reply-to: <20171207112950.GA8258@chaz.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mail-followup-to: Zsh hackers list <zsh-workers@xxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20171207112950.GA8258@chaz.gmail.com>
2017-12-07 11:29:50 +0000, Stephane Chazelas:
[...]
> > /* We don't maintain a hash table in non-interactive shells. */
> > if (!interact)
> > return;
[...]
If I remove that code, that breaks one of the tests:
> --- /tmp/zsh.ztst.2996/ztst.out 2017-12-07 21:31:18.051388484 +0000
> +++ /tmp/zsh.ztst.2996/ztst.tout 2017-12-07 21:31:18.047388673 +0000
> @@ -1,4 +1,4 @@
> ~/install/cvs/zsh/Test/options.tmp
> -~/install/cvs/zsh/Test/options.tmp/tmpcd ~/install/cvs/zsh/Test/options.tmp
> -~/install/cvs/zsh/Test/options.tmp/tmpcd ~/install/cvs/zsh/Test/options.tmp/tmpcd ~/install/cvs/zsh/Test/options.tmp
> -~/install/cvs/zsh/Test/options.tmp/tmpcd ~/install/cvs/zsh/Test/options.tmp/tmpcd ~/install/cvs/zsh/Test/options.tmp
> +~cdablevar2 ~/install/cvs/zsh/Test/options.tmp
> +~cdablevar2 ~cdablevar2 ~/install/cvs/zsh/Test/options.tmp
> +~cdablevar2 ~cdablevar2 ~/install/cvs/zsh/Test/options.tmp
> Test ./E01options.ztst failed: output differs from expected as shown above for:
> dirs
> pushd $mydir/tmpcd
> dirs
> pushd $mydir/tmpcd
> dirs
> setopt pushdignoredups
> pushd $mydir/tmpcd
> dirs
> unsetopt pushdignoredups
> popd >/dev/null
> popd >/dev/null
> Was testing: PUSHD_IGNOREDUPS option
> ./E01options.ztst: test failed.
That's because an earlier test does a cd a:
cd cdablevar2
under setopt cdablevars with cdablevar2 containing that same
tmpcd directory, and so an entry is added in that hash.
That's one case where an earlier test has side effects on later
tests.
While the documentation doesn't mentions that that "hashing" only
happens in interactve shells, the test code acknowleges it to
some extent:
># Test various shell options.
># Interactive options not tested here:
[...]
># AUTO_NAME_DIRS (named directory table not maintained)
That also means:
$ zsh -fc 'cd ~bin; dirs'
/bin
$ zsh -fic 'cd ~bin; dirs'
~bin
BTW, I just realised that named dirs in variables took precedence
over user home dirs:
$ zsh -fc 'cd -P -- ~bin && pwd'
/bin
$ bin=/tmp zsh -fc 'cd -P -- ~bin && pwd'
/tmp
Is that intentional? I can't say I like the idea. It would need
to be disabled in "sh" emulation if we wanted to be POSIX
compliant in that regard (but then there are a few other
namespace clashes that would need to be addressed like for
keywords, special variables if we wanted to go all the way
there).
--
Stephane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author