From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10386 invoked by alias); 18 Jul 2012 14:31:33 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 30575 Received: (qmail 19121 invoked from network); 18 Jul 2012 14:31:22 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at csr.com does not designate permitted sender hosts) Date: Wed, 18 Jul 2012 14:40:17 +0100 From: Peter Stephenson To: Subject: Re: (:a) specifier for not existent files Message-ID: <20120718144017.11d3de3d@pwslap01u.europe.root.pri> In-Reply-To: References: Organization: Cambridge Silicon Radio X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.101.10.18] X-Scanned-By: MailControl 7.7.2 (www.mailcontrol.com) on 10.71.0.123 On Wed, 18 Jul 2012 15:12:49 +0200 Stefan Reich=C3=B6r wrote: > I am using the (:a) specifier to get absoulte file paths. But this works > only for existing files. Is there a way to make it work for not existing > files also? Not in general, because it can't sanity check the path so it doesn't know what to do to it. But you can handle some simple cases: if [[ ! -e $1 ]]; then local dir=3D${1:h} if [[ -d $dir ]]; then dir=3D(${dir}(:a)) 1=3D${dir[1]}/${1:t} fi fi This works for names without a slash since ${1:h} returns ".". --=20 Peter Stephenson Software Engineer Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, = UK Member of the CSR plc group of companies. CSR plc registered in England and= Wales, registered number 4187346, registered office Churchill House, Cambr= idge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom More information can be found at www.csr.com. Follow CSR on Twitter at http= ://twitter.com/CSR_PLC and read our blog at www.csr.com/blog