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

Is anybody maintaining c2z and lete2ctl?



I noticed they haven't changed for quite some time (at least, not in the
zsh 3.0.x sources, I haven't checked 3.1.x).

Here are a batch of tweaks to the 3.0.4 c2z:

* Fix the usage comment
 (can't give both -l and -i, must use one or the other)
* Optionally take the name of a file to convert
  (instead of always converting .cshrc and optionally also .login)
* Use $ZSH_NAME in preference to $VERSION to detect zsh
  (hopefully nobody exports ZSH_NAME and then runs `sh')
* Change $cwd to $PWD in aliases converted to functions
* Delete assignment to PWD from the environment
* Fix handling of tcsh `correct' variable
  (what was `setopt autocorrect' supposed to do?)
* Upcase all `prompt' variables
  (zsh maps prompt->PROMPT but not prompt2->PROMPT2 et. al.)
* Change `!' to `%h' in PROMPT
  (old csh history number references)

There are probably other tcsh-isms that could be incorporated.

Index: Misc/c2z
--- c2z	1997/06/27 16:55:18	1.1.1.1
+++ c2z	1997/09/11 16:40:18
@@ -20,7 +20,7 @@
 # procedures.
 #
 # usage:
-#	c2z [-i] [-l]
+#	c2z [-i | -l | filename]
 #
 # You can use this script in your .zshrc or .zlogin files to load your
 # regular csh environment into zsh; for example, in .zlogin:
@@ -39,27 +39,30 @@
 # If we're zsh, we can run "- csh" to get the complete environment.
 #
 MINUS=""
-LOGIN=""
+LOADFILE=""
 INTERACT=""
-case "$VERSION" in
+CSH=csh
+case "$ZSH_NAME$ZSH_VERSION$VERSION" in
 zsh*)
     case $1 in
     -l*) MINUS="-" ;;
     -i*) INTERACT="-i" ;;
+    *) LOADFILE="source $1" CSH="csh -f";;
     esac
     if [[ -o INTERACTIVE ]]; then INTERACT="-i"; fi
     setopt nobanghist
     ;;
 *)
     case $1 in
-    -l*) LOGIN="source ~/.login" ;;
+    -l*) LOADFILE="source ~/.login" ;;
     -i*) INTERACT="-i" ;;
+    *) LOADFILE="source $1" CSH="csh -f";;
     esac
     ;;
 esac
 
-( eval $MINUS csh $INTERACT ) <<EOF 2>&1 >/dev/null
-$LOGIN
+( eval $MINUS $CSH $INTERACT ) <<EOF 2>&1 >/dev/null
+$LOADFILE
 alias >! /tmp/cz$$.a
 setenv >! /tmp/cz$$.e
 set >! /tmp/cz$$.v
@@ -79,6 +82,7 @@
     -e 's/^\([^'"$T"']*\)'"$T"'\(.*\)$/alias -- \1='"'\2'/" \
     /tmp/cz$$.3
 sed -e 's/![:#]*/$/g' \
+    -e 's/\$cwd/$PWD/' \
     -e 's/^\([^'"$T"']*\)'"$T"'\(.*\)$/\1 () { \2 }/' \
     /tmp/cz$$.2
 
@@ -87,6 +91,7 @@
 
 # Would be nice to deal with embedded newlines, e.g. in TERMCAP, but ...
 sed -e '/^SHLVL/d' \
+    -e '/^PWD/d' \
     -e "s/'/'"\\\\"''"/g \
     -e "s/^\([A-Za-z0-9_]*=\)/export \1'/" \
     -e "s/$/'/"
@@ -101,16 +106,19 @@
 	s/$/'"'/"'
 	}' |
 sed -e '/^argv=/d' -e '/^cwd=/d' -e '/^filec=/d' -e '/^status=/d' \
+	 -e '/^autolist=/s/.*/setopt autolist/' \
+	 -e '/^correct=all/s//setopt correctall/' \
+	 -e '/^correct=/s//setopt correct/' \
 	 -e '/^histchars=/s//HISTCHARS=/' \
 	 -e '/^history=/s//HISTSIZE=/' \
 	 -e '/^home=/s//HOME=/' \
 	 -e '/^ignoreeof=/s/.*/setopt ignoreeof/' \
 	 -e '/^noclobber=/s/.*/setopt noclobber/' \
 	 -e '/^notify=/d' \
+	 -e '/^prompt=/s/!/%h/' \
+	 -e 's/^prompt/PROMPT/' \
 	 -e '/^showdots=/s/.*/setopt globdots/' \
-    -e '/^savehist=/s//HISTFILE=\~\/.zhistory SAVEHIST=/' \
-	 -e '/^autolist=/s/.*/setopt autolist/' \
-	 -e '/^correct=[cmd]*/s//setopt autocorrect/' \
+	 -e '/^savehist=/s//HISTFILE=\~\/.zhistory SAVEHIST=/' \
 	 -e '/^who=/s//WATCHFMT=/'
 
 

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com



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