Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: 3.1.5 - Functions/ and Misc/
- X-seq: zsh-workers 4471
- From: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxxx
- Subject: PATCH: 3.1.5 - Functions/ and Misc/
- Date: Sat, 31 Oct 1998 02:10:47 -0800
Further improvement to multicomp: Drop the special-case for exactly-matched
directories, because it only worked a small fraction of the time anyway.
Discussed with PWS in zsh-workers/4344.
Fix quoting in randline as suggested by PWS in zsh-workers/4410.
Handle several more obsure alias-quoting special cases in c2z.
Index: Functions/multicomp
===================================================================
diff -u -r1.1.1.2 -r1.5
--- multicomp 1998/10/30 15:56:58 1.1.1.2
+++ multicomp 1998/10/30 17:52:42 1.5
@@ -5,8 +5,6 @@
# Usage: e.g.
# compctl -D -f + -U -Q -S '' -K multicomp
#
-# Note that exactly matched directories are not expanded, e.g.
-# s/zsh-2.4/s<TAB> will not expand to src/zsh-2.4old/src.
# Will expand glob patterns already in the word, but use complete-word,
# not TAB (expand-or-complete), or you will get ordinary glob expansion.
# Requires the -U option to compctl.
@@ -42,32 +40,27 @@
[[ "$pref" = /* ]] && sofar=(${sofar}/) && pref="${pref#/}"
head="${pref%%/*}"
pref="${pref#$head}"
- if [[ -n "$pref" && -z $sofar[2] && -d "${sofar}$head" ]]; then
- # Exactly matched directory: don't try to glob
- reply=("${sofar}$head")
+ [[ -z "$pref" ]] && globdir=
+ # if path segment contains wildcards, don't add another.
+ if [[ "$head" = *[\[\(\*\?\$\~]* ]]; then
+ wild=$head
else
- [[ -z "$pref" ]] && globdir=
- # if path segment contains wildcards, don't add another.
- if [[ "$head" = *[\[\(\*\?\$\~]* || -z "$head" ]]; then
- wild=$head
- else
- # Simulate case-insensitive globbing for ASCII characters
- wild="[${(j(][))${(s())head:l}}]*" # :gs/a/[a]/ etc.
- # The following could all be one expansion, but for readability:
- wild=$wild:gs/a/aA/:gs/b/bB/:gs/c/cC/:gs/d/dD/:gs/e/eE/:gs/f/fF/
- wild=$wild:gs/g/gG/:gs/h/hH/:gs/i/iI/:gs/j/jJ/:gs/k/kK/:gs/l/lL/
- wild=$wild:gs/m/mM/:gs/n/nN/:gs/o/oO/:gs/p/pP/:gs/q/qQ/:gs/r/rR/
- wild=$wild:gs/s/sS/:gs/t/tT/:gs/u/uU/:gs/v/vV/:gs/w/wW/:gs/x/xX/
- wild=$wild:gs/y/yY/:gs/z/zZ/:gs/-/_/:gs/_/-_/:gs/[]//
-
- # Expand on both sides of '.' (except when leading) as for '/'
- wild="${${wild:gs/[.]/*.*/}#\*}"
- fi
+ # Simulate case-insensitive globbing for ASCII characters
+ wild="[${(j(][))${(s())head:l}}]*" # :gs/a/[a]/ etc.
+ # The following could all be one expansion, but for readability:
+ wild=$wild:gs/a/aA/:gs/b/bB/:gs/c/cC/:gs/d/dD/:gs/e/eE/:gs/f/fF/
+ wild=$wild:gs/g/gG/:gs/h/hH/:gs/i/iI/:gs/j/jJ/:gs/k/kK/:gs/l/lL/
+ wild=$wild:gs/m/mM/:gs/n/nN/:gs/o/oO/:gs/p/pP/:gs/q/qQ/:gs/r/rR/
+ wild=$wild:gs/s/sS/:gs/t/tT/:gs/u/uU/:gs/v/vV/:gs/w/wW/:gs/x/xX/
+ wild=$wild:gs/y/yY/:gs/z/zZ/:gs/-/_/:gs/_/-_/:gs/[]//
- reply=(${sofar}"${wild}${globdir}")
- reply=(${~reply})
+ # Expand on both sides of '.' (except when leading) as for '/'
+ wild="${${wild:gs/[.]/*.*/}#\*}"
fi
+ reply=(${sofar}"${wild}${globdir}")
+ reply=(${~reply})
+
[[ -z $reply[1] ]] && reply=() && break
[[ -n $pref ]] && sofar=($reply)
done
@@ -77,4 +70,3 @@
[[ -n "$origtop" ]] && reply=("$origtop"${reply#$newtop})
# }
-
Index: Functions/randline
===================================================================
diff -u -r1.1.1.1 -r1.2
--- randline 1998/06/01 17:08:43 1.1.1.1
+++ randline 1998/10/07 04:25:46 1.2
@@ -1,3 +1,3 @@
# get a random line from a file
-integer z=$(wc -l <$1)
+integer z="$(wc -l <$1)"
sed -n $[RANDOM%z+1]p $1
Index: Misc/c2z
===================================================================
diff -u -r1.1.1.1 -r1.2
--- c2z 1998/06/01 17:08:43 1.1.1.1
+++ c2z 1998/10/28 06:47:18 1.2
@@ -3,6 +3,7 @@
# c2z - environment conversion tool
# Contributed by Bart Schaefer
# (Tweaked a bit by Paul Falstad)
+# (Tweaked again by Bart Schaefer)
#
# This is a quick script to convert csh aliases to zsh aliases/functions.
# It also converts the csh environment and local variables to zsh. c2z
@@ -81,7 +82,13 @@
sed -e "s/'/'"\\\\"''"/g \
-e 's/^\([^'"$T"']*\)'"$T"'\(.*\)$/alias -- \1='"'\2'/" \
/tmp/cz$$.3
-sed -e 's/![:#]*/$/g' \
+sed -e 's/>\(&*\)!/>\1|/g' \
+ -e 's/!\*:q/"$@"/g' \
+ -e 's/\(![:#]*[^'"$T"']*\):q/"\1"/g' \
+ -e 's/!\([-0-9][0-9]*\)\(:x\)*/$\2(fc -nl \1)/g' \
+ -e 's/\$:x(fc/$=(fc/g' \
+ -e 's/![:#]*\([^'"$T"']\)/$==\1/g' \
+ -e 's/\$=\(=[^'"$T"']*\):x/$\1/g' \
-e 's/\$cwd/$PWD/' \
-e 's/^\([^'"$T"']*\)'"$T"'\(.*\)$/\1 () { \2 }/' \
/tmp/cz$$.2
@@ -92,6 +99,7 @@
# Would be nice to deal with embedded newlines, e.g. in TERMCAP, but ...
sed -e '/^SHLVL/d' \
-e '/^PWD/d' \
+ -e '/^_=/d' \
-e "s/'/'"\\\\"''"/g \
-e "s/^\([A-Za-z0-9_]*=\)/export \1'/" \
-e "s/$/'/"
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Messages sorted by:
Reverse Date,
Date,
Thread,
Author