delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/09/03/10:40:43

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
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
To: cygwin AT cygwin DOT com
From: Christopher Cobb <ccobb AT email DOT com>
Subject: Re: Problem executing a .bat script in a directory with spaces using bash
Date: Fri, 3 Sep 2004 14:40:27 +0000 (UTC)
Lines: 51
Message-ID: <loom.20040903T163722-711@post.gmane.org>
References: <5c8adab704090207557a3a359a AT mail DOT gmail DOT com> <4137566C DOT 7070203 AT sbcglobal DOT net> <5c8adab704090210405ea696e4 AT mail DOT gmail DOT com> <413760BD DOT 2080504 AT sbcglobal DOT net> <5c8adab70409021123291886c7 AT mail DOT gmail DOT com> <41376CD2 DOT 9090102 AT comcast DOT net> <41376D75 DOT 1060806 AT comcast DOT net> <loom DOT 20040903T154613-572 AT post DOT gmane DOT org> <Pine DOT GSO DOT 4 DOT 61 DOT 0409030951520 DOT 28876 AT slinky DOT cs DOT nyu DOT edu>
Mime-Version: 1.0
X-Complaints-To: usenet AT sea DOT gmane DOT org
X-Gmane-NNTP-Posting-Host: main.gmane.org
User-Agent: Loom/3.14 (http://gmane.org/)
X-Loom-IP: 162.70.244.40 (Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040803 Firefox/0.8)
X-IsSubscribed: yes

Igor Pechtchanski <pechtcha <at> cs.nyu.edu> writes:
> I believe you're missing the point.  Try
> 
> ./test.bat "hello world"
> 
> and you'll get the error.

I use the following shell function cmd() to invoke batch files.  It removes
cygwinisms from the PATH and the environment first and does some argument
pre-processing.  It also seems to fix the space problem.

chcobb AT CHCOBB-054009 /c/Documents and Settings 10:36:09
508$ cat test.bat
echo %1

chcobb AT CHCOBB-054009 /c/Documents and Settings 10:38:30
509$ cmd test "Hello, world."

C:\Documents and Settings>echo "Hello, world." 
"Hello, world."


--- cmd() ---
cmd () 
{ 
    ( local c="`cygpath -w \"$1\"`";
    shift;
    local cmd=`cygpath -u $COMSPEC`;
    while [ $# != 0 ]; do
        if [ -f "$1" ]; then
            local args="$args '`cygpath -w $1`'";
        else
            if [ -d "$1" ]; then
                local args="$args '`cygpath -w $1 | sed 's@\\\\\$@@'`'";
            else
                local args="$args '$1'";
            fi;
        fi;
        shift;
    done;
    PATH=`echo $PATH |
          tr : '\n' |
          egrep -vw '^(/usr/local/bin|/usr/bin|/bin|/usr/X11R6/bin)$' |
          tr '\n' :`;
    unset BASH_ENV COLORTERM CYGWIN DISPLAY HISTCONTROL MAKE_MODE;
    unset MANPATH PKG_CONFIG_PATH PS1 PWD SHLVL TERM USER _;
    unset CVS CVSROOT CVS_RSH GEN_HOME GROOVY_HOME TOMCAT_DIR;
    eval $cmd /c "$c" $args )
}
--- end cmd() ---



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