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: latest cygwin: 'run' problem


On 09/09/2014 03:15 AM, Achim Gratz wrote:

> 
> If you want to get this right, you should work it out from the inside.
> You want the cd command to get a directory name from a subcommand that
> may contain spaces, so you need to quote the result:
> 
> cd "$( ... )"
> 

If you want to also guarantee that you can change to a relative
directory whose name begins with a -, you need:

cd -- "$( ... )"

> Since the argument you're getting may actually be a filename, you need
> to use the dirname command and quote its argument again:
> 
> cd "$(/bin/dirname "$(...)")"

Again, if you have the possibility of a relative directory name that
might begin with dash,

cd -- "$(/bin/dirname -- "$(...)")"

> 
> and dirname gets its argument from cygpath, and the argument to cygpath
> must itself be quoted again:
> 
> cd "$("$(/bin/dirname "$(/bin/cygpath -u "$1")")")"

Ah - you are using cygpath, which can guarantee an absolute name (and
therefore avoid an argument beginning with dash).

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


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