This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: cygpath -m behaviour change


On Thu, Sep 19, 2013 at 3:23 PM, David Griffiths
<david.griffiths@gmail.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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]