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

Re: autocd in scripts



On Sat, Nov 8, 2014 at 5:44 AM, Clint Hepner <clint.hepner@xxxxxxxxx> wrote:
>
> A question on Stack Overflow recently asked about using the AUTO_CD option
> in a script

My first reaction to this would be "Why?" -- under what circumstances
would you want to obscure the fact that the script is changing
directories? -- but to return to the direct question ...

> I couldn't find anything in the documentation
[but]
> the SHIN_STDIN option needs to be in effect as well:
>
> I realize AUTO_CD is intended as an interactive feature, but requiring commands be read
> from standard input seems like a proxy for checking if the shell is interactive. I was
> wondering if there was a reason for this specific check, and if it could either be relaxed
> or documented with AUTO_CD.

The SHINSTDIN test has been part of autocd farther back than any
changelog or source control can resolve, so it's probably related to
cd printing out the name of the new directory whenever an autocd takes
place, and the assumption is that this would not be wanted when the
input is from a script file (but simply changing silently would also
be bad).

This probably should be documented somehow.  Suggested wording, anyone?



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