This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: need help with bash -c <command> with cygpath


-----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@byu.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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]