From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3871 invoked by alias); 15 Jan 2016 09:55:35 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 21150 Received: (qmail 5461 invoked from network); 15 Jan 2016 09:55:34 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 X-IBM-Helo: d06dlp01.portsmouth.uk.ibm.com X-IBM-MailFrom: vogt@linux.vnet.ibm.com X-IBM-RcptTo: zsh-users@zsh.org Date: Fri, 15 Jan 2016 10:45:26 +0100 From: Dominik Vogt To: zsh-users@zsh.org Subject: Re: cd "" foo bug? Message-ID: <20160115094526.GA11215@linux.vnet.ibm.com> Reply-To: vogt@linux.vnet.ibm.com Mail-Followup-To: zsh-users@zsh.org References: <20160111112026.GA14816@linux.vnet.ibm.com> <20160111115804.00a8661b@pwslap01u.europe.root.pri> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160111115804.00a8661b@pwslap01u.europe.root.pri> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16011509-0025-0000-0000-0000089F0DED 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/ 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 -, +, -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