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

autocd in scripts



A question on Stack Overflow recently asked about using the AUTO_CD option
in a script,
as it did not appear to work. I couldn't find anything in the documentation
about it, but a
peek at exec.c revealed that for

    setopt autocd
    mkdir foo
    foo
    # $pwd is now foo

to work, the SHIN_STDIN option needs to be in effect as well:

    # Src/exec.c, execcmd()
    char trycd = (isset(AUTOCD) && isset(SHINSTDIN) &&
                      (!redir || empty(redir)) && args && !empty(args) &&
                      !nextnode(firstnode(args)) && *(char
*)peekfirst(args));

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.

Clint


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