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
<> 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

CURRENT_DIR=$(dirname "$0")

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

case $(uname) in
    CURRENT_DIR=$(cygpath -wa "$CURRENT_DIR")
    CURRENT_DIR=$(cd "$CURRENT_DIR" && pwd)

"$JAVA_HOME/bin/java" "$CURRENT_DIR"

Kind regards


remember.guy do |as, often| as.you_can - without end

Problem reports:
Unsubscribe info:

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