Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

RE: zsh for win32 - installation of zshrc



i put in code to hash foo.exe as foo as well as foo.exe

bogus corrections should be reduced a bit by this.

(check for version 0.50)
thanks,
-amol

> ----------
> From: 	Bart Schaefer[SMTP:schaefer@xxxxxxxxxxxxxxxx]
> Sent: 	Tuesday, September 15, 1998 5:55 PM
> To: 	zsh-users@xxxxxxxxxxxxxxx
> Subject: 	Re: zsh for win32 - installation of zshrc
> 
> On Sep 15,  2:56pm, Amol Deshpande wrote:
> > > 
> > > "setopt correct" is worthless because it uses the full file name (e.g.
> > > "foo.exe") when trying to correct the spelling of a command ("foo")
> and
> > > therefore complains about nearly everything except builtins.  (This is
> > > probably fixable by playing with hash/unhash commands.)
> > > 
> > it's actually fixable by just renaming all your foo.exes to foo :-)
> 
> I wrote this little fragment of code to fix it (still not handling all
> the possible extensions, just .exe):
> 
> function fixhash {
>   emulate -R zsh
>   setopt localoptions
>   local hashed exe
>   hash -f
>   eval hashed=\( $(hash) \)
>   exe=( ${(M)hashed:#*.[Ee][Xx][Ee]\=*} )
>   hashed=( ${hashed%%\=*} )
>   hashed=( ${hashed:#*.[Ee][Xx][Ee]} )
>   hashed=( ${(M)hashed:#*.*} )
>   [[ $#hashed -gt 0 ]] && unhash $hashed
>   [[ $#exe -gt 0 ]] && hash ${exe:l:s/.exe//}
> }
> 
> However, running that function takes a LONG time and then crashes the
> shell.
> Right before the shell crashes, the $hashed array is 1349 elements long
> and
> contains just over 16000 bytes.
> 
> If I don't put the commands in a function, simply type everything from the
> "hash -f" to the end directly at the PS1 prompt (or put it in .zshrc),
> then
> it still takes a long time -- particularly "eval hashed=\( $(hash) \)" --
> but the shell doesn't crash.
> 
> > For example,  HOMDRIVE=F:,  and HOMEPATH=\
> > so, if  FOO=$HOMEDRIVE$HOMEPATH,  then FOO is set
> > to F:\.
> > 
> > this will confuse the shell no end (all paths MUST be '/'-delimited)
> 
> Hmm, that's interesting.  Right now I have HOME=d:\home\schaefer and I
> don't have winntconvertbackslash and the shell seems to be doing fine.
> (Everything in $PATH is forward-slash-delimited, though.)
> 
> > in tcsh i could just do
> > 
> > set bar=$var:s#\\#/#:ah  
> > 
> > but I was told there was no simple way in zsh to do the same.
> 
> bar=${var:gs@\\@/@}
> 
> works fine.  Going the other way is trickier:
> 
> var=${bar:gs@/@\\\\@}
> 
> I don't know why the extra two backslashes are needed.  Anyone?
> 
> > BTW, please don't cc amol@xxxxxxxxxx
> 
> Sorry; my UA copied the Cc: from your own headers.  (I've been deleting
> amold@xxxxxxxxxxxxx from the To: header by hand).
> 



Messages sorted by: Reverse Date, Date, Thread, Author