www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2008/01/11/17:02:27

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
To: cygwin AT cygwin DOT com
From: Jay <jmandawg AT hotmail DOT com>
Subject: Re: need help with bash -c <command> with cygpath
Date: Fri, 11 Jan 2008 22:01:16 +0000 (UTC)
Lines: 57
Message-ID: <loom.20080111T215048-569@post.gmane.org>
References: A<loom DOT 20080111T150132-291 AT post DOT gmane DOT org> <2D9E96311DCA4C48BF185EA6928BC7BB030AAB8D AT asc-mail DOT int DOT ascribe DOT com> <01a501c85470$647dde60$2e08a8c0 AT CAM DOT ARTIMI DOT COM> <4787E0A0 DOT 3010102 AT byu DOT net>
Mime-Version: 1.0
User-Agent: Loom/3.14 (http://gmane.org/)
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.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

Eric Blake <ebb9 <at> byu.net> writes:

> 
> 
> According to Dave Korn on 1/11/2008 9:38 AM:
> |   I believe what is needed is 1) outer double-quotes, for cmd's benefit, 2)
> | inner single-quotes, for bash's benefit, 3) double up the slashes /as well/,
> | because there's one more level of quoting being stripped than I can account
> | for, but anyway it works for me:
> |
> | C:\Documents and Settings\dk>C:\cygwin\bin\bash -v -x -c
> "'\\\\UNC_PATH\\Dir'"
> | '\\UNC_PATH\Dir'
> | + '\\UNC_PATH\Dir'
> | /usr/bin/bash: \\UNC_PATH\Dir: command not found
> 
> "'\\'" - the " quotes are stripped and \\ collapsed by cmd.exe => '\'
> '\' - the ' quotes are stripped by bash on execution => \
> 
> |   If I wasn't trying to execute a directory but list it instead, I'd say
> |
> | C:\cygwin\bin\bash -v -x -c "ls -la '\\\\UNC_PATH\\Dir'"
> 
> Which means:
> 
> bash -vxc "ls -la \\\\\\\\UNC_PATH\\\\Dir"
> 
> will also work (8 leading \ converted to 4 by cmd, then 4 converted to 2
> by bash, so that ls sees an argument with 2 leading \).

Thanks everyone for the help.  Since i'm getting the path from the registry i
can't add in the extra backslashes without using sed.  I ended up with this
registy key which seems to work for local drives as well as network drives
(UNCs) (haven't tested files with special characters).

(manually typed into the registry)
C:\cygwin\bin\bash -v -c "/usr/bin/head \"$(/usr/bin/echo '%1' | /usr/bin/sed
's#^\\\\\(\w\)#\\\\\\\\\1#;s#\\\#\/#g')\" | /cygdrive/c/John/Tools/vim/gvim.exe
-R -" 

Here is the regfile if anyone wants to try it out.  You will prob need to change
your path to gvim, or just use the path to cygwin vim.

--START REGFILE---
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\Head2Vim]

[HKEY_CLASSES_ROOT\*\shell\Head2Vim\Command]
@="C:\\cygwin\\bin\\bash -v -c \"/usr/bin/head \\\"$(/usr/bin/echo '%1' |
/usr/bin/sed 's#^\\\\\\\\\\(\\w\\)#\\\\\\\\\\\\\\\\\\1#;s#\\\\\\#\\/#g')\\\" |
/cygdrive/c/John/Tools/vim/gvim.exe -R -\" "

--END REGFILE--
 




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