zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Roman Perepelitsa <roman.perepelitsa@gmail.com>
Cc: Dian M Fay <dian.m.fay@gmail.com>,
	Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: [PATCH] expand '..n' to equivalent number of '..' segments in fixdir
Date: Sat, 9 May 2020 22:58:32 -0700	[thread overview]
Message-ID: <CAH+w=7ayhozLXTYTE_3NEn9rKeR7-XrobddNpVFmB0xJEHBMGw@mail.gmail.com> (raw)
In-Reply-To: <CAN=4vMr_8j03P2oY0+9SLgBnMWMtGtrnUag7fte=18VnvUtRKg@mail.gmail.com>

On Sat, May 9, 2020 at 9:44 PM Roman Perepelitsa
<roman.perepelitsa@gmail.com> wrote:
>
> On Sun, May 10, 2020 at 6:36 AM Dian M Fay <dian.m.fay@gmail.com> 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 $*
}

  reply	other threads:[~2020-05-10  5:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-10  4:37 Dian M Fay
2020-05-10  4:43 ` Roman Perepelitsa
2020-05-10  5:58   ` Bart Schaefer [this message]
2020-05-10  6:28     ` Bart Schaefer
2020-05-10 17:17       ` Dian M Fay
     [not found] <CAN=4vMr_8j03P2oY0+9SLgBnMWMtGtrnUag7fte =18VnvUtRKg@mail.gmail.com>
2020-05-10  5:28 ` Dian M Fay
2020-05-10  7:06   ` Eric Cook
2020-05-10  7:09     ` Eric Cook
2020-05-10 14:21       ` Daniel Shahaf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH+w=7ayhozLXTYTE_3NEn9rKeR7-XrobddNpVFmB0xJEHBMGw@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=dian.m.fay@gmail.com \
    --cc=roman.perepelitsa@gmail.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).