summaryrefslogtreecommitdiff
path: root/Misc
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2007-07-03 17:06:04 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2007-07-03 17:06:04 +0000
commit876fa2c44e0a17b2d10a2547ac1d13687cfed520 (patch)
treef92ce7475c97f82a05e20e9ba8be9b83436c9b6b /Misc
parent6fa964914d8be709b1145399108ef1535a0b3f39 (diff)
downloadzsh-876fa2c44e0a17b2d10a2547ac1d13687cfed520.tar.gz
zsh-876fa2c44e0a17b2d10a2547ac1d13687cfed520.zip
unposted: force latest version of files from vendor to main branch
Diffstat (limited to 'Misc')
-rw-r--r--Misc/.distfiles4
-rw-r--r--Misc/bash2zshprompt17
-rwxr-xr-xMisc/c2z10
-rw-r--r--Misc/compctl-examples20
-rwxr-xr-xMisc/globtests.ksh13
-rw-r--r--Misc/job-control-tests45
-rwxr-xr-xMisc/lete2ctl49
7 files changed, 133 insertions, 25 deletions
diff --git a/Misc/.distfiles b/Misc/.distfiles
index a02614511..4e6a00aac 100644
--- a/Misc/.distfiles
+++ b/Misc/.distfiles
@@ -1,4 +1,6 @@
DISTFILES_SRC='
.distfiles
- c2z compctl-examples globtests globtests.ksh lete2ctl
+ bash2zshprompt
+ c2z compctl-examples globtests globtests.ksh
+ job-control-tests lete2ctl make-zsh-urls
'
diff --git a/Misc/bash2zshprompt b/Misc/bash2zshprompt
index aa0472ed1..7fc11434e 100644
--- a/Misc/bash2zshprompt
+++ b/Misc/bash2zshprompt
@@ -10,7 +10,7 @@ use strict;
my @colours = qw/grey red green yellow blue magenta cyan white/;
my @codes = ();
-my %bold;
+my %boldp;
my $out = '';
print "# Converted to zsh prompt theme by bash2zshprompt, written by <adam\@spiers.net>\n";
@@ -25,7 +25,7 @@ while (<>) {
# UGH
elsif (! $seen_fn_end && $seen_fn) {
s/^\s*/ /;
- s/^\s*}\s*$/\n precmd () { }\n preexec () { }\n}\n/ and $seen_fn_end++;
+ s/^\s*}\s*$/\n precmd () { setopt promptsubst }\n preexec () { }\n}\n/ and $seen_fn_end++;
}
s/\\\[/%{/g;
@@ -44,6 +44,8 @@ while (<>) {
s/(?<!\\)\\#/%!/g; # hmmm
s/(?<!\\)\\n/\$prompt_newline/g;
s/(?<!\\)\\s/\$SHELL/g;
+ s/(?<!\\)\\v/\$ZSH_VERSION[1]/g;
+ s/(?<!\\)\\V/\${ZSH_VERSION%%-*}/g;
s/(?<!\\)\\w/%~/g;
s/(?<!\\)\\W/%1~/g;
s/(?<!\\)\\\$(?!\()/%\#/g;
@@ -78,21 +80,22 @@ sub color {
($p[1] eq '4') ? 'bg' :
'???');
- $bold{$fgbg} ||= '';
+ $boldp{$fgbg} ||= '';
if ($p[0] =~ /^0?0$/) {
- $bold{$fgbg} = '';
+ $boldp{$fgbg} = '';
return '$reset_color';
}
if ($p[0] =~ /^0?1$/) {
- $bold{$fgbg} = 'bold_';
+ $boldp{$fgbg} = 'bold_';
return '$bold_color';
}
return '$' .
- "${fgbg}_$bold{$fgbg}" .
- $colours[$p[2]];
+ "${fgbg}$boldp{$fgbg}\[" .
+ $colours[$p[2]] .
+ ']';
}
sub split_codes {
diff --git a/Misc/c2z b/Misc/c2z
index 8a90d5fd8..534137296 100755
--- a/Misc/c2z
+++ b/Misc/c2z
@@ -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 @@ grep -v ! /tmp/cz$$.1 >/tmp/cz$$.3
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 @@ exec < /tmp/cz$$.e
# 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/$/'/"
diff --git a/Misc/compctl-examples b/Misc/compctl-examples
index e84a37fbb..1b9fc0ac8 100644
--- a/Misc/compctl-examples
+++ b/Misc/compctl-examples
@@ -11,15 +11,15 @@
# page.
#
#------------------------------------------------------------------------------
-hosts=("${${(s: :)${(s: :)${${(f)$(</etc/hosts)}%%\#*}#*[ ]*}}:#}")
-ports=( "${${${(f)$(</etc/services)}:#\#*}%%[ ]*}" )
+hosts=( ${(s: :)${(ps:\t:)${${(f)"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}} )
+ports=( "${(@)${(@)${(@f)$(</etc/services)}:#\#*}%%[ ]*}" )
# groups=( $(cut -d: -f1 /etc/group) )
# groups=( $(ypcat group.byname | cut -d: -f1) ) # if you use NIS
# It can be done without forking, but it used too much memory in old zsh's:
-groups=( "${${(f)$(</etc/group)}%%:*}" )
-#groups=( "${${(f)$(ypcat groups)}%%:*}" ) # if you use NIS
+groups=( ${${(s: :)$(</etc/group)}%%:*} )
+#groups=( ${${(s: :)$(ypcat groups)}%%:*} ) # if you use NIS
# Completion for zsh builtins.
compctl -z -P '%' bg
@@ -251,7 +251,7 @@ compctl -k ftphosts ftp
# Note that 'r[-exec,;]' must come first
if [[ -r /proc/filesystems ]]; then
# Linux
- filesystems='"${${(f)$(</proc/filesystems)}#* }"'
+ filesystems='"${(@)${(@f)$(</proc/filesystems)}#* }"'
else
filesystems='ufs 4.2 4.3 nfs tmp mfs S51K S52K'
fi
@@ -563,7 +563,7 @@ cvsprefix() {
cvsentries() {
setopt localoptions nullglob unset
if [[ -f ${pref}CVS/Entries ]]; then
- reply=( "${pref}${^${${${(f@)$(<${pref}CVS/Entries)}:#D*}#/}%%/*}" )
+ reply=( "${pref}${(@)^${(@)${(@)${(f@)$(<${pref}CVS/Entries)}:#D*}#/}%%/*}" )
fi
}
@@ -574,7 +574,7 @@ cvstargets() {
}
cvsrevisions() {
- reply=( "${${${(M)${(f)$(cvs -q status -vl .)}:# *}##[ ]##}%%[ ]*}" )
+ reply=( "${(@)${(@)${(@M)${(@f)$(cvs -q status -vl .)}:# *}##[ ]##}%%[ ]*}" )
}
cvsrepositories() {
@@ -582,7 +582,7 @@ cvsrepositories() {
[[ -f CVS/Root ]] && root=$(<CVS/Root)
reply=(
$root/^CVSROOT(:t)
- "${${(M)${(f)$(<$root/CVSROOT/modules)}:#[^#]*}%%[ ]*}"
+ "${(@)${(@M)${(@f)$(<$root/CVSROOT/modules)}:#[^#]*}%%[ ]*}"
)
}
@@ -622,7 +622,7 @@ compctl -s '$(rpm -qa)' \
'c[-1,--rcfile]' -f - \
'p[1] s[-b]' -k '(p l c i b a)' - \
'c[-1,--queryformat] N[-1,{]' \
- -s '"${${(f)$(rpm --querytags)}#RPMTAG_}"' -S '}' - \
+ -s '"${(@)${(@f)$(rpm --querytags)}#RPMTAG_}"' -S '}' - \
'W[1,-q*] C[-1,-([^-]*|)f*]' -f - \
'W[1,-i*], W[1,-q*] C[-1,-([^-]*|)p*]' \
-/g '*.rpm' + -f -- rpm
@@ -635,7 +635,7 @@ compctl -K talkmatch talk ytalk ytalk3
function talkmatch {
local u
reply=($(users))
- for u in "${${(f)$(rwho 2>/dev/null)}%%:*}"; do
+ for u in "${(@)${(@f)$(rwho 2>/dev/null)}%%:*}"; do
reply=($reply ${u%% *}@${u##* })
done
}
diff --git a/Misc/globtests.ksh b/Misc/globtests.ksh
index b03cc488e..6a9bf9b0e 100755
--- a/Misc/globtests.ksh
+++ b/Misc/globtests.ksh
@@ -1,6 +1,6 @@
#!/usr/local/bin/zsh -f
-setopt kshglob
+setopt kshglob extendedglob
failed=0
while read res str pat; do
@@ -68,6 +68,7 @@ t foobar !(foo)*
t moo.cow !(*.*).!(*.*)
f mad.moo.cow !(*.*).!(*.*)
f mucca.pazza mu!(*(c))?.pa!(*(z))?
+f _foo~ _?(*[^~])
t fff !(f)
t fff *(!(f))
t fff +(!(f))
@@ -87,5 +88,15 @@ t zoox @(!(z*)|*x)
t foo *(!(foo))
f foob !(foo)b*
t foobb !(foo)b*
+t fooxx (#i)FOOXX
+f fooxx (#l)FOOXX
+t FOOXX (#l)fooxx
+f fooxx (#i)FOO@(#I)X@(#i)X
+t fooXx (#i)FOO@(#I)X@(#i)X
+t fooxx @((#i)FOOX)x
+f fooxx @((#i)FOOX)X
+f BAR @(bar|(#i)foo)
+t FOO @(bar|(#i)foo)
+t Modules (#i)*m*
EOT
print "$failed tests failed."
diff --git a/Misc/job-control-tests b/Misc/job-control-tests
index 7e35fba0b..ecb9a7694 100644
--- a/Misc/job-control-tests
+++ b/Misc/job-control-tests
@@ -29,3 +29,48 @@ while true; do sed -e 's/foo/bar/' Src/builtin.c >/dev/null; done
# ignoring the error messages from sed.
# ^Z is more of a problem since you have to catch the sed.
while true; do sed -e 's/foo/bar/' non-existent-file >/dev/null; done
+
+# Try
+# ^Z
+# fg
+# ^Z
+# fg
+fn() {
+ local a
+ while read a; do :; done
+ less "$@"
+}
+cat foo | fn bar
+
+# Try
+# ^Z
+# fg
+fn() {
+ cat builtin.c
+}
+fn | while read a; do :; done
+
+# Try
+# ^Z
+# fg
+# q
+# ^Z
+# fg
+# q
+fn() {
+ less builtin.c
+ echo done
+}
+x=2; while (( x-- )); do f; done
+
+# Try
+# ^C
+# This won't work because zcat doesn't tell us that it received a signal.
+# But
+# ^Z
+# fg
+# ^C (probably a second ^C is needed: if the continued zcat is still running)
+# works.
+# (See also the file Etc/BUGS)
+while true; do zcat foo.gz > /dev/null; done
+
diff --git a/Misc/lete2ctl b/Misc/lete2ctl
index ca00b8aee..273ea4674 100755
--- a/Misc/lete2ctl
+++ b/Misc/lete2ctl
@@ -9,6 +9,7 @@
# Runs as a filter. Should ignore anything which isn't a "complete".
# It expects each "complete" statement to be the first thing on a line.
# All the examples in the tcsh manual give sensible results.
+# Author: Peter Stephenson <pws@ibmth.df.unipi.it>
#
# Option:
# -x (exact): only applies in the case of command disambiguation (is
@@ -38,6 +39,11 @@
# (5) Make sure all command names with wildcards are processed together --
# they need to be lumped into one "compctl -C" or "compctl -D"
# statement for zsh.
+# (6) Group completion (complete's g flag) is not built into zsh, so
+# you need perl to be available to generate the groups. If this
+# script is useful, I assume that's not a problem.
+# (7) I don't know what `completing completions' means, so the X
+# flag to complete is not handled.
# Handle options
if (@ARGV) {
@@ -113,6 +119,13 @@ sub gettype {
# Nothing (n) can be handled by returning nothing. (C.f. King Lear, I.i.)
if ($c =~ /[abcjuv]/) {
$ret = "-$c";
+ } elsif ($c eq 'C') {
+ if (defined($glob)) {
+ $ret = "-W $glob -/g '*(.*)'";
+ undef($glob);
+ } else {
+ $ret = '-c';
+ }
} elsif ($c eq 'S') {
$ret = '-k signals';
} elsif ($c eq 'd') {
@@ -121,18 +134,42 @@ sub gettype {
} else {
$ret = '-/';
}
+ } elsif ($c eq 'D') {
+ if (defined($glob)) {
+ $ret = "-W $glob -/";
+ undef($glob);
+ } else {
+ $ret = '-/';
+ }
} elsif ($c eq 'e') {
$ret = '-E';
} elsif ($c eq 'f' && !$glob) {
$ret = '-f';
+ } elsif ($c eq 'F') {
+ if (defined($glob)) {
+ $ret = "-W $glob -f";
+ undef($glob);
+ } else {
+ $ret = '-f';
+ }
+ } elsif ($c eq 'g') {
+ $ret = "-s '\$(perl -e '\\''while ((\$name) = getgrent)\n" .
+ "{ print \$name, \"\\n\"; }'\\'')'";
} elsif ($c eq 'l') {
$ret = q!-k "(`limit | awk '{print $1}'`)"!;
} elsif ($c eq 'p') {
- $ret = "-W $glob -f", undef($glob) if defined($glob);
+ $ret = "-W $glob -f", undef($glob) if defined($glob);
} elsif ($c eq 's') {
- $ret = '-p';
+ $ret = '-p';
} elsif ($c eq 't') {
$qual = '.';
+ } elsif ($c eq 'T') {
+ if (defined($glob)) {
+ $ret = "-W $glob -g '*(.)'";
+ undef($glob);
+ } else {
+ $ret = "-g '*(.)'";
+ }
} elsif ($c eq 'x') {
$glob =~ s/'/'\\''/g;
$ret = "-X '$glob'";
@@ -190,7 +227,7 @@ $" = " - ";
while (<>) {
if (/^\s*complete\s/) {
- undef(@stuff);
+ undef(@stuff);
$default = '';
$_ = $';
while (/\\$/) {
@@ -211,7 +248,7 @@ while (<>) {
# Loop over remaining arguments to "complete".
$sep = substr($word,1,1);
$sep =~ s/(\W)/\\$1/g;
- @split = split(/$sep/,$word);
+ @split = split(/$sep/,$word,4);
for ($i = 0; $i < 3; $i++) {
while ($split[$i] =~ /\\$/) {
substr($split[$i],-1,1) = "";
@@ -225,7 +262,9 @@ while (<>) {
# The "complete" catch-all: treat this as compctl\'s
# default (requiring no pattern matching).
$default .= &gettype($type) . ' ';
- defined($suffix) && ($defsuf .= $suffix);
+ defined($suffix) &&
+ (defined($defsuf) ? ($defsuf .= $suffix)
+ : ($defsuf = $suffix));
} else {
$pat = &getpat($pat,$arg);
$type = &gettype($type);