delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2008/01/09/09:25:24

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
X-Authority-Analysis: v=1.0 c=1 a=8YBfKGRHcpkA:10 a=xe8BsctaAAAA:8 a=eRYEq1GinYHUgGCG5okA:9 a=Qsb8T-iBzRfYOaa-OPIA:7 a=aHmnKPyKToaJI2tD_Mr2c9XjrPkA:4 a=eDFNAWYWrCwA:10 a=rPt6xJ-oxjAA:10
Message-ID: <4784D93C.10803@byu.net>
Date: Wed, 09 Jan 2008 07:25:00 -0700
From: Eric Blake <ebb9 AT byu DOT net>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071031 Thunderbird/2.0.0.9 Mnenhy/0.7.5.666
MIME-Version: 1.0
To: cygwin AT cygwin DOT com, jmandawg AT hotmail DOT com
Subject: Re: need help with bash -c <command> with cygpath
References: <loom DOT 20080109T014917-334 AT post DOT gmane DOT org> <47845595 DOT 5040406 AT byu DOT net> <loom DOT 20080109T133322-382 AT post DOT gmane DOT org>
In-Reply-To: <loom.20080109T133322-382@post.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

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Jay on 1/9/2008 7:13 AM:
|> Whoa - it seldom makes sense to use -i and -c simultaneously - what good
|
| What i'm actually trying to do is have a right-click menu in windows so that
| when i right click on a file i can choose head from the context menu, and it
| will send the top 10 lines of the file to vim.  I have gvim (windows
version)
| aliased in my .bashrc so that's why i'm using the -i switch.

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?

|
| What i have done is created the following registry key:
| [HKEY_CLASSES_ROOT\*\shell\Head\Command]
| with the (default) value set to:
| C:\CYGWIN\bin\bash -i -c "head $(cygpath -a '%1') | vim -R -"

Why didn't you say so in the first place?  Windows registry quoting rules
are different than bash quoting rules.  And now you are getting into the
realm of cygwin applicability.  You may be interested in examining how the
cygwin package chere solves this same sort of problem.

Your biggest problem is that you want a single argument passed to -c, but
which contains proper quoting rules for bash.  In isolation, you want the
above command to look like:

bash -c 'head "$(cygpath -a '%1')" | vim -R -'

So now you have to figure out the escape sequences to get

'head "$(cygpath -a '%1')"'

stored into the registry - probably something like (untested):

"'head ""$(cygpath -a '%1')""'

or

"'head \"$(cygpath -a '%1')\"'

| Maybe i have the quotes messed up, or maybe i'm going about doing this
all wrong.

It's all in the quoting.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             ebb9 AT byu DOT net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHhNk884KuGfSFAYARAg7ZAKDGWpkFVfkFQtLOzBD6EFv9Lfz2QwCg1uOB
tTwXD3Bts5S5tFX74c5U/nw=
=MZLe
-----END PGP SIGNATURE-----

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