delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2013/09/17/05:12:35

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:mime-version:in-reply-to:references:date
:message-id:subject:from:to:content-type; q=dns; s=default; b=Fw
dXeiwJwbjBcjLAMeH+NcEnnb0wyWFiHBA+WT88J/cRaGiZx883mT2j8aQF4YkJhY
/S1FtLggVEF7J9avurDyxNk3+zY9H+vGV86qMc5d+GhhxtsmjlfQi4ofZM6/T3qr
5RDK5VfSnDi9mHdqyqOgnwDkrOX3yg1adFebYrtEM=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:mime-version:in-reply-to:references:date
:message-id:subject:from:to:content-type; s=default; bh=2inYLT0D
6gYTvcXmplLtixTW5wI=; b=ZzQ2ajnqDMJGYwhd0LUOIbwF2tEwdLl1DxgnCX4i
7HVEXFEQ4HwBJuLfHmOT6/64shZmrR4mp7qP9BzpjOWgwo9sRgggjDXGj+UArRik
WVirk1n9FHw7bmVmPKWL3Vkdt9R9q9CGzxNMWI+PgKM3SgbBdBjxilannKpjvd56
3Gk=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=1.1 required=5.0 tests=AWL,BAYES_50,FREEMAIL_FROM,KHOP_THREADED,NO_RELAYS autolearn=ham version=3.3.2
X-HELO: mail-qe0-f47.google.com
MIME-Version: 1.0
X-Received: by 10.49.105.1 with SMTP id gi1mr51970298qeb.8.1379409137164; Tue, 17 Sep 2013 02:12:17 -0700 (PDT)
In-Reply-To: <CAF+hkWo0jXKKLM8pS8gZLG0rak+wcLpWJdS2He2_=MxYb0gpYw@mail.gmail.com>
References: <CAF+hkWo0jXKKLM8pS8gZLG0rak+wcLpWJdS2He2_=MxYb0gpYw AT mail DOT gmail DOT com>
Date: Tue, 17 Sep 2013 11:12:17 +0200
Message-ID: <CAM9pMnPLLjZs3RAzg1tOgREH45-vP22tTT_3Pzob86POBXh=UQ@mail.gmail.com>
Subject: Re: cygpath -m behaviour change
From: Robert Klemme <shortcutter AT googlemail DOT com>
To: cygwin AT cygwin DOT com
X-IsSubscribed: yes

On Mon, Sep 16, 2013 at 11:56 AM, David Griffiths
<david DOT griffiths AT gmail DOT com> wrote:
>> Yes, that's exactly right, assuming that 'boo' doesn't exist.
>
> Hi, it happens even if boo does exist. To put it in context, the
> script in question was attempting to determine the current directory:
>
> CURRENT_DIR=$(cygpath -ma "${0}"/../)

I am confused: do they need the current directory or the directory
where the script resides?  The use of -m also sounds a bit weird to
me.  I'd rather use -u or -w depending on who is supposed to use the
value (i.e. a Windows process or a Unix Cygwin process).

> (I didn't write this script but I assume they did this for performance reasons.)

For the same I'd rather do

DIR_OF_SCRIPT=$(dirname "$0") && test -d "$DIR_OF_SCRIPT" || exit 1

> But anyway, as you can see ${0} always exists.

$ dash -c 'echo $0; for a; do echo "arg: $a"; done'
dash
$ dash -c 'echo $0; for a; do echo "arg: $a"; done' bla
bla
$ dash -c 'echo $0; for a; do echo "arg: $a"; done' bla foo
bla
arg: foo
$ dash -c 'echo $0; for a; do echo "arg: $a"; done' -- bla foo
--
arg: bla
arg: foo

Kind regards

robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019