Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Implement CDPATH mechanism in Zsh script
- X-seq: zsh-users 21846
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: Implement CDPATH mechanism in Zsh script
- Date: Wed, 7 Sep 2016 00:52:43 -0700
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed;        d=brasslantern-com.20150623.gappssmtp.com; s=20150623;        h=from:message-id:date:in-reply-to:comments:references:to:subject         :mime-version;        bh=jSQbYVL9DoVJ1QNcFNV6zWiGE2+2weKRrCEH2HViIXU=;        b=AlQ2WoYBLgktxw3ab0OilnD052XhPpu198w17p5qOL3fCbifuCn8rQAZwKBdQfuygL         PADfr9vMFn02Tr+8+wTbE/EclQ8FboY/9SX6Jhbjxt48Ev1vH+q2QFuuY8LqGgOZklJu         +eQs9xcOCgslnJf5GlCWSW8wwuCutlB8qiXQiC30jYXS/Xi2bxpLtQP0mgoesC8BcVjj         XkUNX4AF9AIMosMYSrp5eJRkZabn9bbb9zTO4GXRhl9oBX/kuKBwHaB8Ns7tlGVqB2Mu         QZZPyMDjhGIE3TdF2DEOvp0MjrrSV0xo8mWkYL3Lz/MR2ddkYxrB+vHUcj8OOJsICqih         EX8A==
- In-reply-to: <CAKc7PVAZqTKQ2aXzQHT1D7kx2-KbwaTGWgKeXJ9JwkKFugO38w@mail.gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CAKc7PVABbS7gD6DkJSU4g_uxLCQ=79LrCC=CP9_0s-YefOgeJg@mail.gmail.com> 	<160906230442.ZM11332@torch.brasslantern.com> 	<CAKc7PVAZqTKQ2aXzQHT1D7kx2-KbwaTGWgKeXJ9JwkKFugO38w@mail.gmail.com>
On Sep 7,  8:13am, Sebastian Gniazdowski wrote:
}
} On 7 September 2016 at 08:04, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
} wrote:
} 
} > Or are you trying to predict how the current directory is going to be
} > changed by "cd", without actually executing "cd"?
} 
} Ah, it's about prediction
The most obvious/foolproof thing would be to use a subshell:
    newPWD=$(cd -q $where >&/dev/null && pwd)
Next would be globbing:
    # Assumes last component of $cdpath is "."
    cdWD=( $^cdpath/$where(N[1]) )
    newPWD=${cdWD:A}
Note this is exactly what :A is supposed to be for, but it gives the
wrong result if CHASE_LINKS or CHASE_DOTS is set, so you may need the
new :P modifier, or the :a modifier instead.  [[ -o ... ]] tests left
as an exercise.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author