X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org To: cygwin AT cygwin DOT com From: Jay Subject: Re: need help with bash -c with cygpath Date: Fri, 11 Jan 2008 22:01:16 +0000 (UTC) Lines: 57 Message-ID: References: A <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 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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: List-Subscribe: List-Archive: List-Post: List-Help: , 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 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/