From 876fa2c44e0a17b2d10a2547ac1d13687cfed520 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Tue, 3 Jul 2007 17:06:04 +0000 Subject: unposted: force latest version of files from vendor to main branch --- Misc/.distfiles | 4 +++- Misc/bash2zshprompt | 17 ++++++++++------- Misc/c2z | 10 +++++++++- Misc/compctl-examples | 20 ++++++++++---------- Misc/globtests.ksh | 13 ++++++++++++- Misc/job-control-tests | 45 +++++++++++++++++++++++++++++++++++++++++++++ Misc/lete2ctl | 49 ++++++++++++++++++++++++++++++++++++++++++++----- 7 files changed, 133 insertions(+), 25 deletions(-) (limited to 'Misc') 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 \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/(?/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)$(/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 # # 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); -- cgit 1.4.1