delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/05/14/21:07:38

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/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
Message-ID: <3EC2E7BB.5080703@mscha.org>
Date: Thu, 15 May 2003 03:04:59 +0200
From: Michael Schaap <cygwin AT mscha DOT org>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4b) Gecko/20030506 Thunderbird/0.1a
X-Accept-Language: en-us, en
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: Does cygstart always expand arguments?
References: <Pine DOT GSO DOT 4 DOT 44 DOT 0305131935510 DOT 17480-100000 AT slinky DOT cs DOT nyu DOT edu> <3EC1A7A6 DOT 7020504 AT kleckner DOT net>
In-Reply-To: <3EC1A7A6.7020504@kleckner.net>
X-Virus-Scanned: by amavisd-milter 0.1 @ mscha.org (http://www.amavis.org/)

Jim Kleckner wrote:

>
> Igor Pechtchanski wrote:
>
>> On Tue, 13 May 2003, Jim Kleckner wrote:
>
> ...
>
>> FYI, the following works for me:
>>
>> cygstart gvim '"file with spaces.txt"' '"another file with spaces.txt"'
>
>
> Yep, you did it, thanks!  A gold star for you, though
> definitely not as valuable as cgf's.
>
> Another case of peeling off layers of
> "quoting the quotes".  There must be some
> DOS shell buried in there as part of the
> invocation or something. 

No DOS shell involved here.  (cygstart directly calls the Win32 API 
ShellExecute function.)  It's actually the (UNIX) shell which peels of 
the quotes.
I'll make some changes to cygstart so that arguments with whitespace 
will be (re-)quoted.  I should be able to do this at the latest this 
weekend.

(Note that this won't be 100% backwards compatible - for instance, this 
breaks the above workaround.  But I think we can live with that, it's 
better than the current behaviour.)

>
>
> If anyone cares, here is a small bash
> snippet that will create either a shell
> alias or a function to figure out which
> version of gvim/vim/vimx/vi is available
> to use.
>
Here's mine:

    vi()
    {
        local args=""
        local arg dir

        # Loop through arguments to command
        for arg; do

            # Is it an existing file?  Translate to Windows format
            if [[ -f "$arg" ]]; then
                # Use short name iff filename contains space
                if [[ "$arg" != ${arg/ /} ]]; then
                    arg=`cygpath -w -s "$arg"`
                else
                    arg=`cygpath -w "$arg"`
                fi

            # Or is it a non-existing file in an existing directory (not 
.)?  Also
            # translate to Windows format
            else
                dir=`dirname $arg`
                if [[ "$dir" != "" && "$dir" != "." && -d "$dir" ]]; then
                    arg=`cygpath -w $arg`
                fi
            fi

            args="$args $arg"
        done

        # Run gvim
        gvim $args <&0 &
        disown
    }

Note that I don't use cygstart, but run 'disown' to solve the 'problem' 
of job ownership.
(Actually, this is my Bash version of this function.  in my Zsh version, 
which I use normally, I run "gvim $args <&0 &!" instead.)

 - Michael


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

- Raw text -


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