delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2008/01/11/10:51:59

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
MIME-Version: 1.0
Subject: RE: Re: need help with bash -c <command> with cygpath
Date: Fri, 11 Jan 2008 15:51:12 -0000
Message-ID: <2D9E96311DCA4C48BF185EA6928BC7BB030AAB8D@asc-mail.int.ascribe.com>
In-Reply-To: A<loom.20080111T150132-291@post.gmane.org>
From: "Phil Betts" <Phil DOT Betts AT ascribe DOT com>
To: <cygwin AT cygwin DOT com>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
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
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id m0BFpmrX011762

Jay wrote on Friday, January 11, 2008 3:14 PM::

>> That's still somewhat wasteful, starting bash just to get a vim
>> alias - why not use the full name gvim, and bypass the bash process
>> to begin with? 
> 
> you right, i'm going to remove it, thanks.
> 
> My main problem now is that for some reason the leading backslash on
> UNC names is getting dropped when calling bash -c from the windows
> command prompt, even when using just single quotes.  So if you run
> this from a windows command prompt: 
> 
> H:\>C:\cygwin\bin\bash -v -c '\\UNC_PATH\Dir'
> \UNC_PATH\Dir   <--Leading backslash dropped
> /usr/bin/bash: UNC_PATHDir: command not found
> 
> It drops off the leading backslash.
> 
> When you run it from Cygwin bash:
>> bash -v -c '\\UNC_PATH\Dir'
> \\UNC_PATH\Dir       <--The leading backslash is preserved.
> bash: \UNC_PATHDir: command not found
> 
> I know i can make it work by piping the path into sed, but I'm just
> wondering why i'm losing the leading backslash when running from
> windows. 
> 
> Maybe dos is passing in the single quotes as double quotes.
> 

"dos" (i.e. cmd.exe) does not have the same quoting rules as bash,
so \\ inside single quotes means the same as it does inside double
quotes in bash.

Why are you even trying to use backslashes?  There's no need (even
in cmd.exe), but there's certainly no point in using them in a posix
command.  Just replace all backslashes with forward slashes and you've
sidestepped the problem.

If you absolutely MUST have backslashes, from cmd.exe, you need to 
double each backslash:

H:\>C:\cygwin\bin\bash -v -c '\\\\UNC_PATH\\Dir'

(actually only the first really needs to be doubled, because \ has
no special meaning if it's followed by a letter)

Phil

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