zsh-users
 help / color / mirror / code / Atom feed
From: Dominik Vogt <vogt@linux.vnet.ibm.com>
To: zsh-users@zsh.org
Subject: Re: cd "" foo bug?
Date: Fri, 15 Jan 2016 10:45:26 +0100	[thread overview]
Message-ID: <20160115094526.GA11215@linux.vnet.ibm.com> (raw)
In-Reply-To: <20160111115804.00a8661b@pwslap01u.europe.root.pri>

On Mon, Jan 11, 2016 at 11:58:04AM +0000, Peter Stephenson wrote:
> On Mon, 11 Jan 2016 12:20:26 +0100
> # should handle options up here...
> 
> if (( $# == 2 )); then
>   local src=$1 rep=$2 dir
>   integer n=1
>   while true; do
>     dir=${(I:${n}:)PWD/$src/$rep}
>     if [[ $dir = $PWD ]]; then
>       print -r "$0: no replacements found: $PWD / \"$src\" / \"$rep\"" >&2
>       return 1
>     fi
>     if [[ -d $dir ]]; then

>       cd -- $dir

How is this supposed to work?  The manual does not mention "--":

  http://zsh.sourceforge.net/Doc/Release/Shell-Builtin-Commands.html#Shell-Builtin-Commands

The shell silently accepts it but seems to completely ignore it:

  $ zsh --version
  zsh 5.0.2 (s390x-ibm-linux-gnu)

  $ mkdir /tmp/-1
  $ builtin cd /tmp
  # note: pushdminus and autopushd are on
  $ builtin cd -- -1
  ~
  $ pwd
  /home/<user>

But on the other hand it works with -- as the directory name:

  $ mkdir /tmp/--
  $ builtin cd /tmp
  $ builtin cd -- --
  $ pwd
  /tmp/--

As far as I can see there is no direct way to pass -<n>, +<n>, -q,
-s, -L or -P as a directory argument to the cd builtin.  -- is
undocumented but works like in many other Unix tools, but not when
used with one of the options above.  -- works fine with
two-argument cd calls.

>       return
>     fi
>     (( n++ ))
>   done
> else
>   builtin cd "$@"
> fi

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany


  reply	other threads:[~2016-01-15  9:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-11 11:20 Dominik Vogt
2016-01-11 11:58 ` Peter Stephenson
2016-01-15  9:45   ` Dominik Vogt [this message]
2016-01-15 10:41     ` Peter Stephenson
2016-01-15 11:29       ` Dominik Vogt
2016-01-15 19:34         ` Bart Schaefer

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=20160115094526.GA11215@linux.vnet.ibm.com \
    --to=vogt@linux.vnet.ibm.com \
    --cc=zsh-users@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).