* Cygwin Zsh auto-cygpath?
@ 2009-02-07 20:53 Benjamin R. Haskell
2009-02-09 16:15 ` Peter Stephenson
2009-02-09 17:17 ` Nikolai Weibull
0 siblings, 2 replies; 5+ messages in thread
From: Benjamin R. Haskell @ 2009-02-07 20:53 UTC (permalink / raw)
To: Zsh Users
On Windows machines, I use Zsh under Cygwin. The more I use it, the more
frequently I find myself using:
"$(cygpath -w /path/to/some/file)"
For those who don't use Cygwin, that "Windows-ifies" the path.
e.g.
$ pwd
/cygdrive/c/Documents and Settings/bhaskell/My Documents
$ cygpath -w $PWD
C:\Documents and Settings\bhaskell\My Documents
It's necessary to do that for most Windows-native commands, since they
don't (and shouldn't) know about the '/cygdrive' prefix, and usually don't
handle forward-slash'ed paths.
I was wondering if there was a simple way to have the _files completer
output "$(cygpath -w /path/stuff)". Has anyone created something like
that? Or could someone point me to where I'd want to insert that into the
completion process?
(This is the first time I've seriously considered delving into 'man
zshcompsys', but I unfortunately don't have that kind of time right
now...) :-\
Best,
Ben
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Cygwin Zsh auto-cygpath?
2009-02-07 20:53 Cygwin Zsh auto-cygpath? Benjamin R. Haskell
@ 2009-02-09 16:15 ` Peter Stephenson
2009-02-09 16:41 ` Benjamin R. Haskell
2009-02-09 17:17 ` Nikolai Weibull
1 sibling, 1 reply; 5+ messages in thread
From: Peter Stephenson @ 2009-02-09 16:15 UTC (permalink / raw)
To: Zsh Users
"Benjamin R. Haskell" wrote:
> I was wondering if there was a simple way to have the _files completer
> output "$(cygpath -w /path/stuff)".
Completely replacing the output of a completion functions may be doable
though is likely to be icky, but note that if you define a function
cyg() {
reply=("$(cygpath -w $REPLY)")
}
in a recent version of the shell then you can put "(+cyg)" (minus
quotes, with parentheses---it's a glob qualifer) after any file name to
convert it.
--
Peter Stephenson <pws@csr.com> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Cygwin Zsh auto-cygpath?
2009-02-09 16:15 ` Peter Stephenson
@ 2009-02-09 16:41 ` Benjamin R. Haskell
0 siblings, 0 replies; 5+ messages in thread
From: Benjamin R. Haskell @ 2009-02-09 16:41 UTC (permalink / raw)
To: Zsh Users
On Mon, 9 Feb 2009, Peter Stephenson wrote:
> "Benjamin R. Haskell" wrote:
>> I was wondering if there was a simple way to have the _files completer
>> output "$(cygpath -w /path/stuff)".
>
> Completely replacing the output of a completion functions may be doable
> though is likely to be icky, but note that if you define a function
>
> cyg() {
> reply=("$(cygpath -w $REPLY)")
> }
>
> in a recent version of the shell then you can put "(+cyg)" (minus
> quotes, with parentheses---it's a glob qualifer) after any file name to
> convert it.
Oooh. Very cool. I like that. And, it's probably what I'll stick with.
But as a followup, and not necessarily for only this situation...
How hard is it to extend csh-style modifiers -- to do, e.g. $param:+cyg ?
Thanks,
Ben
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Cygwin Zsh auto-cygpath?
2009-02-07 20:53 Cygwin Zsh auto-cygpath? Benjamin R. Haskell
2009-02-09 16:15 ` Peter Stephenson
@ 2009-02-09 17:17 ` Nikolai Weibull
2009-02-09 18:14 ` Cygwin Zsh auto-cygpath? (OT) Benjamin R. Haskell
1 sibling, 1 reply; 5+ messages in thread
From: Nikolai Weibull @ 2009-02-09 17:17 UTC (permalink / raw)
To: Benjamin R. Haskell; +Cc: Zsh Users
On Sat, Feb 7, 2009 at 21:53, Benjamin R. Haskell <zsh@benizi.com> wrote:
... most Windows-native commands, ... usually don't handle
forward-slash'ed paths.
If they don't then they are actually broken, as a forward slash is
defined to be a path separator on Windows systems. Of course, few
realize that, and it seems few of those that do bother to handle it.
There's more information at
http://blogs.msdn.com/larryosterman/archive/2005/06/24/432386.aspx
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Cygwin Zsh auto-cygpath? (OT)
2009-02-09 17:17 ` Nikolai Weibull
@ 2009-02-09 18:14 ` Benjamin R. Haskell
0 siblings, 0 replies; 5+ messages in thread
From: Benjamin R. Haskell @ 2009-02-09 18:14 UTC (permalink / raw)
To: Zsh Users
On Mon, 9 Feb 2009, Nikolai Weibull wrote:
> On Sat, Feb 7, 2009 at 21:53, Benjamin R. Haskell <zsh@benizi.com> wrote:
>
> ... most Windows-native commands, ... usually don't handle
> forward-slash'ed paths.
>
> If they don't then they are actually broken, as a forward slash is
> defined to be a path separator on Windows systems. Of course, few
> realize that, and it seems few of those that do bother to handle it.
Huh, neat. I didn't realize (until tangentially looking it up on
Wikipedia[1]) that NTFS accommodates POSIX filenames (only the null
character and '/' are always forbidden in NTFS filenames.) In "Win32"
mode, it still excludes '\' (the path separator) plus the forbidden seven:
/:*?"<>
An article from the MSDN Library[2] (which is an interesting read if you
have to deal with Windows) seems to corroborate your "If they don't then
they are actually broken":
"""
File I/O functions in the Windows API convert "/" to "\" as part of
converting the name to an NT-style name, except when using the "\\?\"
prefix as detailed in the following sections.
"""
Which, I suppose, makes "cmd" broken. (In more ways than it already
seemed.) As a quick test, out of 'dir', 'copy', 'move', 'type', and 'cd',
only 'cd' accepts forward slashes[3]. Windows PowerShell handles them
all.
> There's more information at
> http://blogs.msdn.com/larryosterman/archive/2005/06/24/432386.aspx
Thanks for the history (especially after following some of the
hyperlinks).
Best,
Ben
[1] http://en.wikipedia.org/wiki/NTFS
[2] "Naming a File or Directory (Windows)"
http://msdn.microsoft.com/en-us/library/aa365247.aspx
[3] ==== output from Start > Run > cmd ====
C:\>dir WINDOWS\system\test.txt
Volume in drive C has no label.
Volume Serial Number is ECD7-AF25
Directory of C:\WINDOWS\system
2009/02/09 12:32 16 test.txt
1 File(s) 16 bytes
0 Dir(s) 118,255,886,336 bytes free
C:\>dir WINDOWS/system/test.txt
Parameter format not correct - "system".
C:\>copy WINDOWS/system/test.txt .
The syntax of the command is incorrect.
C:\>move WINDOWS/system/test.txt .
The system cannot find the path specified.
C:\>type WINDOWS/system/test.txt
The syntax of the command is incorrect.
C:\>type WINDOWS\system\test.txt
this is test.txt
C:\>cd WINDOWS/system
C:\WINDOWS\system>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-02-09 18:15 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-07 20:53 Cygwin Zsh auto-cygpath? Benjamin R. Haskell
2009-02-09 16:15 ` Peter Stephenson
2009-02-09 16:41 ` Benjamin R. Haskell
2009-02-09 17:17 ` Nikolai Weibull
2009-02-09 18:14 ` Cygwin Zsh auto-cygpath? (OT) Benjamin R. Haskell
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).