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

Re: Prompt dir expansion after removing cwd's parent



> On 08 June 2022 at 10:14 Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
> 
> 
> With 5.9:
> 
>      1	% cd /tmp
>      2	% PS1='%~%# '
>      3	/tmp% mkdir foo foo/bar 
>      4	/tmp% cd foo/bar
>      5	/tmp/foo/bar% rm -rf /tmp/foo
>      6	/tmp/foo/bar% cd ..
>      7	/tmp/foo/bar% cd ..
>      8	/tmp% 
> 
> The prompts on lines 6 and 7 are wrong.
> 
> Ideally I'd like to see some indication that cwd has been deleted, or
> that a path to cwd couldn't be determined, etc..  Definitely not some
> apprently-valid path that points to something else than cwd.

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.
Presumably a getcwd() is needed each time the prompt is updated.
We also need to decide how to signal this.

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.  For both, bash gives
the more logical

pwd: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory

pws




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