From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27784 invoked by alias); 27 Oct 2010 17:07:23 -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: 15510 Received: (qmail 20780 invoked from network); 27 Oct 2010 17:07:22 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at benizi.com designates 64.130.10.15 as permitted sender) Date: Wed, 27 Oct 2010 12:57:32 -0400 (EDT) From: "Benjamin R. Haskell" To: zsh-users@zsh.org Subject: Re: Absolute path of a path In-Reply-To: <20101027164454.GA19471@prunille.vinc17.org> Message-ID: References: <20101027164454.GA19471@prunille.vinc17.org> User-Agent: Alpine 2.01 (LNX 1266 2009-07-14) MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="-1463810530-1122968799-1288198676=:3583" ---1463810530-1122968799-1288198676=:3583 Content-Type: TEXT/PLAIN; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8BIT On Wed, 27 Oct 2010, Vincent Lefevre wrote: > On 2010-10-27 11:34:44 +0200, Jérémie Roquet wrote: >> 2010/10/27 Nikolai Weibull>: >>> How do I get the absolute path of a path?  The only thing I can find >>> is the :a modifier for history expansion. >> >> your_path(:a) >> >> For example .(:a) is pwd > > BTW, is there a way to get the canonicalised absolute pathname with > zsh? (i.e. what the "realpath" command gives.) With new enough Zsh, you can use: the ':A' modifier. As a workaround, though, since I have to use older Zsh'es on various systems, I have: # uses Perl, since that tends to be more consistent than 'realpath' # across the systems I was using this on: A () { reply=("$(perl -MCwd=realpath -we 'print realpath shift' $REPLY)") } Then, instead of: your_path(:A) -- returns the realpath in new Zsh'es. you can do: your_path(+A) -- calls the 'A' function above to find the realpath -- Best, Ben ---1463810530-1122968799-1288198676=:3583--