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

Re: Prompt dir expansion after removing cwd's parent



On Wed, Jun 8, 2022 at 2:42 AM Peter Stephenson
<p.w.stephenson@xxxxxxxxxxxx> wrote:
>
> > On 08 June 2022 at 10:14 Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
> >
> > With 5.9:

With any version of zsh ever, really.

> > Ideally I'd like to see some indication that cwd has been deleted, or
> > that a path to cwd couldn't be determined, etc..

IMO this happens so seldom that doing it before every prompt as a
shell default just seems like a huge waste of time, especially if
(say) the current directory is on a networked file system and there
may be a significant delay checking it.  If you're doing this to
yourself often enough to notice, put something in your precmd hooks to
discover it.

> It looks like prompts currently just passively look at the internal pwd
> variable, so make no kind of checks of the environment of any sort.

Intentionally so ...

> However, it looks like this has wider ramifications as it appears
> "pwd" and "pwd -P" both just shrug their shoulders and return
> the last known current directory in this case.

/*
 * Try to find the current directory.
 * If we couldn't work it out internally, fall back to getcwd().
 * If it fails, fall back to pwd; if zgetcwd() is being used
 * to set pwd, pwd should be NULL and we just return ".".
 */

As of workers/50287, we always fall back to getcwd() rather than "work
it out internally", so some of the foregoing may have subtly changed.




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