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

Re: [PATCH] Re: zsh completion for umount



Bart Schaefer wrote on Mon, Oct 31, 2016 at 12:32:52 -0700:
> On Oct 31,  8:06am, Bart Schaefer wrote:
> }
> } The remaining problem is that _canonical_paths_pwd screws up "cd -"
> 
> Patch below attempts to fix that.
> 
> diff --git a/Completion/Unix/Type/_canonical_paths b/Completion/Unix/Type/_canonical_paths
> index 6482602..4b6b0c0 100644
> --- a/Completion/Unix/Type/_canonical_paths
> +++ b/Completion/Unix/Type/_canonical_paths
> @@ -16,11 +16,13 @@
>  _canonical_paths_pwd() {
>    # Get the canonical directory name by changing to it.
>    integer chaselinks
> +  local oldpwd=$OLDPWD
>    [[ -o chaselinks ]] && (( chaselinks = 1 ))
> -  setopt localoptions nopushdignoredups chaselinks
> +  setopt localoptions nopushdignoredups chaselinks noautopushd
>    if builtin pushd -q -- $1 2>/dev/null; then
>      REPLY=$PWD
>      (( chaselinks )) || unsetopt chaselinks
> +    [[ -n $oldpwd && -d $oldpwd ]] && builtin cd -q $oldpwd	# For "cd -"
>      builtin popd -q

Couldn't we avoid calling pushd/cd entirely?  I.e., something along the
lines of

    if [[ -o chaselinks ]]; then REPLY=$1:A; else REPLY=$1:P; fi

?

>    else
>      REPLY=$1
> 



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