Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] expand '..n' to equivalent number of '..' segments in fixdir
- X-seq: zsh-workers 45805
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>
- Subject: Re: [PATCH] expand '..n' to equivalent number of '..' segments in fixdir
- Date: Sat, 9 May 2020 22:58:32 -0700
- Cc: Dian M Fay <dian.m.fay@xxxxxxxxx>, Zsh hackers list <zsh-workers@xxxxxxx>
- In-reply-to: <CAN=4vMr_8j03P2oY0+9SLgBnMWMtGtrnUag7fte=18VnvUtRKg@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <C2MRS2V8S953.3DWB49ORSAIY8@lamia> <CAN=4vMr_8j03P2oY0+9SLgBnMWMtGtrnUag7fte=18VnvUtRKg@mail.gmail.com>
On Sat, May 9, 2020 at 9:44 PM Roman Perepelitsa
<roman.perepelitsa@xxxxxxxxx> wrote:
>
> On Sun, May 10, 2020 at 6:36 AM Dian M Fay <dian.m.fay@xxxxxxxxx> wrote:
> >
> > dian@lamia ~/work/zsh cd ..2
> > dian@lamia ~ cd ..123
> > dian@lamia /
>
> `..2` is a valid directory name. So it's a breaking change.
It can also be implemented as a shell function wrapper around "cd", so
it's not necessary to modify the C code.
Here's the basics, minus necessary handling for other cd options.
cd() {
emulate -L zsh -o extendedglob -o histsubstpattern
while [[ $1 = (#b)((#s)(|*/)..(<->)(/*|)(#e)) ]] do
local dots=${(j:/:)${:-{1..${match[3]}}}//<->/..}
set -- ${1:s,${~match[1]},${match[2]}${dots}${match[4]}}
done
echo builtin cd $*
}
Messages sorted by:
Reverse Date,
Date,
Thread,
Author