delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2013/09/19/10:41:53

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=Yn
YKPJA7UVRqSEi+4lVFbSeBfjMqthXZ3qWxqS0TZdguELupPn38xEzvnTQ0oshyVI
fEraw8Yqi1HoE7k2pZo2r7bsbhXKfLGymgSkb0K/CNsqxQIcOtk9471+Q3oboMH9
+kjC5ra5PHcpRC5RHG3HDqgYjk4rMUYnFFO3w5NvI=
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=JS71eKSI
TZN1uDcuqFu9PaCRQB8=; b=DuyHzPrXcTKm2h0D90k4SuHZ+Q0FylMqCfMUVzCb
Q8Lr82CHMUSInhoA/aasxiNb8LI+BU3PZkxD/oOkg+2dP9EBLuV6GcuSeQUxlzXP
kOGb7QHsGywR10kp1l2I7fJ6h0VX1ul8bEM/+uiQ8dNqYccW+fISvWhXvMz8cDvx
j8s=
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=0.3 required=5.0 tests=AWL,BAYES_05,FREEMAIL_FROM,KHOP_THREADED,NO_RELAYS autolearn=ham version=3.3.2
X-HELO: mail-qe0-f48.google.com
MIME-Version: 1.0
X-Received: by 10.49.130.233 with SMTP id oh9mr4455512qeb.10.1379601697059; Thu, 19 Sep 2013 07:41:37 -0700 (PDT)
In-Reply-To: <CAF+hkWrUP9UuovH19rgocb4+37Q5V8-LPxNLwi+qUYc4qDm5zg@mail.gmail.com>
References: <CAF+hkWrUP9UuovH19rgocb4+37Q5V8-LPxNLwi+qUYc4qDm5zg AT mail DOT gmail DOT com>
Date: Thu, 19 Sep 2013 16:41:36 +0200
Message-ID: <CAM9pMnMONtf5T74O=5HbiGFiQzc1DJGNU_+Ynp-9goP+P-QV3Q@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 Thu, Sep 19, 2013 at 3:23 PM, David Griffiths
<david DOT griffiths AT gmail DOT com> wrote:
>> But why are you even using cygpath to try and determine the containing
>> directory?  'dirname' does that task, in a much more portable manner,
>> and without having to worry about whether 'file/..' can be abused in
>> spite of POSIX semantics
>
> To given even more context, this is how it was used:
>
> uname=`uname`
>
> case $uname in
>   CYGWIN_*)
>     CURRENT_DIR=$(cygpath -ma "${0}\..")
>     ;;
>
>   *)
>     CURRENT_DIR=$(cd $(dirname "$0") && pwd)
> esac
>
> CURRENT_DIR (or something derived from it) ends up getting passed to a
> Java program which requires the absolute pathname in native format.
> The dirname/pwd variant won't do that under cygwin.

I don't understand why there is a difference made with regard to the
directory extraction in Cygwin and others.  I'd probably rather have
done

CURRENT_DIR=$(dirname "$0")

if  [ ! -d "$CURRENT_DIR" ]; then
  echo "ERROR: cannot derive directory from script path: $0" >&2
  exit 1
fi

case $(uname) in
  CYGWIN_*)
    CURRENT_DIR=$(cygpath -wa "$CURRENT_DIR")
    ;;
  *)
    CURRENT_DIR=$(cd "$CURRENT_DIR" && pwd)
   ;;
esac

"$JAVA_HOME/bin/java" foo.bar.Main "$CURRENT_DIR"

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