From 08f335e4851dd626c0a9c4f5e3b0fe661909e6f4 Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Sun, 23 Jan 2000 22:34:02 +0000 Subject: zsh-3.1.6-dev-16 --- ChangeLog | 193 ++++++++++++++++++++++++++++++++++++++++++++- Completion/User/.distfiles | 9 +-- Config/version.mk | 4 +- Doc/Makefile.in | 2 +- Doc/Zsh/.distfiles | 2 +- Functions/Misc/.distfiles | 3 +- Functions/Misc/nslookup | 47 +++++------ Functions/Misc/zmv | 165 ++++++++++++++++++++++++++++++++++++++ Src/Modules/.distfiles | 2 +- Src/builtin.c | 1 - Src/exec.c | 3 +- Src/glob.c | 6 +- Src/init.c | 7 -- Src/zsh.h | 6 -- 14 files changed, 395 insertions(+), 55 deletions(-) create mode 100644 Functions/Misc/zmv diff --git a/ChangeLog b/ChangeLog index 93b806181..1b5123141 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,10 +1,197 @@ +2000-01-23 Peter Stephenson + + * pws: Config/version.mk, Src/Modules/.distfiles: 3.1.6-dev-16; + zprof.mdd, zfprof.c finally added to distribution. + +2000-01-22 Peter Stephenson + + * pws: 9408: Src/pattern.c, Doc/Zsh/expn.yo: failed + backreferences, such as (...)# matching zero times or (|(...)) + matching first part of branch now set match to null string and + indices to -1 instead of crashing the shell. + + * Clint: 9405: Makefile.in: $(DESTDIR) missing in front of + $(sitefndir). + + * Tanaka Akira: 9404: Completion/Core/_path_files: `%' missing in + parameter expansion. + +2000-01-21 Peter Stephenson + + * Sven: 9403: Completion/Core/_path_files, Doc/Zsh/compsys.yo: + brace problems with squeeze-slashes. + + * Sven: 9402: Completion/Builtins/_zstyle, + Completion/Core/_path_files, Doc/Zsh/compsys.yo: ignore-parents + style for more tunable path completion. + + * Sven: 9401: Src/Modules/parameter.c, Src/exec.c, Src/zsh.h: use + list-based instead of function-based system for shell function + wrappers. + + * Sven: 9399: Functions/Zftp/zfinit: bad reverse index. + + * Sven: 9398: Functions/Zftp/zfcd_match, + Functions/Zftp/zfget_match: fix _description calls + + * Sven: 9397: Functions/Zftp/zfinit: incorrect zmodload for + autoloaded builtin + + * Sven: 9396: Doc/Zsh/mod_zle.yo, Src/Zle/zle_main.c: better + retrieval of history in vared. + + * Sven: 9395: Src/exec.c, Src/parse.c, Src/text.c: problems with + ksh-format autoload and core dump due to bad termination in + function execution. + + * Sven: 9388, 9389: Completion/User/_domains: try to completion + host domains better. + +2000-01-20 Peter Stephenson + + * Alexandre: 9387: Doc/Zsh/compsys.yo: document brace problems + with 9383. + + * Sven: 9386: Completion/Core/_multi_parts, + Completion/Core/_sep_parts: both functions support -F option. + + * Alexandre: 9385: Completion/User/_prcs: tilde expansion in prcs + repository path. + + * Alexandre: 9383: Doc/Zsh/compsys.yo, Completion/Core/_path_files, + Completion/Builtins/_zstyle: add squeeze-slashes style not to take + multiple slashes as multiple completable directories; add + file-patterns to zstyle completion. + + * Sven: 9382: Src/Modules/parameter.c, Src/exec.c, Src/mem.c, + Src/parse.c, Src/text.c: fix problems with empty lists in wordcode + programmes and some comments. + + * Sven: 9381: Src/Zle/compresult.c: don't expand parameters quite + so often for tests. + +2000-01-19 Peter Stephenson + + * Sven: 9373: Src/Modules/parameter.c: missing keys with special + parameters. + + * Sven: 9371: Completion/Core/_files, Completion/Core/_path_files, + Doc/Zsh/compsys.yo: file-patterns style for overriding choices for + file completion built into completion functions. + + * Sven: 9370: Src/text.c: missing tstack initialisation. + + * pws: 9367: Src/cond.c, Src/parse.c, Test/04redirect.ztst, + Test/07cond.ztst: fixes for 9332: `[' tests didn't work, skipping + conditions with `&&' and `||' didn't work, always use WC_END + marker to terminate code. + + * Tanaka Akira: 9360: Completion/User/_cvs: new -C option to cvs + update, better descriptions. + + * Tanaka Akira: 9359: Completion/Debian/_apt, + Completion/Base/_regex_arguments: argument handling for apt-cache. + +2000-01-18 Peter Stephenson + + * Sven: 9336: Src/signals.c: addition to 9332. + + * Sven: 9332: Src/Modules/example.c, Src/Modules/parameter.c, + Src/Modules/zftp.c, Src/Modules/zprof.c, Src/Zle/compcore.c, + Src/Zle/compctl.c, Src/Zle/complete.c, Src/Zle/zle_main.c, + Src/Zle/zle_misc.c, Src/builtin.c, Src/cond.c, Src/exec.c, + Src/glob.c, Src/hashtable.c, Src/init.c, Src/loop.c, Src/parse.c, + Src/signals.c, Src/text.c, Src/utils.c, Src/zsh.h: Use word code + instead of structs for passing executable chunks around. + + * pws: 9357: Src/glob.c: speculative but harmless attempt to avoid + alignment problems on sparc/Linux. + + * Sven: 9353: Completion/Base/_jobs: bad prefix test + + * Sven: 9348: Src/Modules/zutil.c: various minor regex fixes + + * Sven: 9345: Src/exec.c, Src/jobs.c, Src/zsh.h: + bug with job control when group leader exits; other problems + with subshells. + + * Alexandre: 9340: Src/Zle/computil.c: bug with adding `=' after + options. + + * Sven: 9335: Completion/Core/_path_files: fix special-dirs style. + +2000-01-17 Peter Stephenson + + * Clint: 9333: Completion/User/_a2ps: a2ps can take PostScript + input files. + + * Johan Sundström: 9331: Doc/Zsh/compwid.yo: typo. + + * Sven: 9330: Src/mem.c: debugging message not needed when using + mmap(). + + * Sven: 9329: Src/Modules/parameter.c, Src/Zle/complete.c, + Src/Zle/zleparameter.c, Src/glob.c, Src/mem.c: memory management + fixes for hashtables and heaps. + +2000-01-16 Peter Stephenson + + * Tanaka Akira: 9328: Completion/User/_finger, + Completion/User/_other_accounts: new finger completion. + .distfiles also updated. + +2000-01-15 Peter Stephenson + + * Tanaka Akira: 9325: Src/init.c: misspelled SITEFPATH_DIR + + * Alexandre: 9324: Completion/User/_tar_archive: .tgz completion + didn't work. + +2000-01-14 Peter Stephenson + + * pws: 9322: INSTALL, Makefile.in, configure.in, + Config/defs.mk.in, Config/funcinst.mk, Config/installfns.sh, + Config/uninstallfns.sh, Src/init.c, Src/zsh.mdd: install.fns + creates site-functions, parallel to /usr/share/zsh/3.1.6-dev-15 + or wherever; no functions.old directory saved or used; functions + directory is version-specific anyway, so just delete old one. + + * Sven: 9318: Src/exec.c, Src/init.c, Src/zsh.h: cases where we + don't need to make up the job text. + + * Tanaka Akira: 9317: Completion/User/_urls: don't quote bookmarks + when inserted. + + * Tanaka Akira: 9316: Completion/User/_cvs: detects zsh/stat + module more carefully. + + * Sven: 9315: Src/module.c: bad error status when using zmodload + in static shell. + + * Tanaka Akira: 9311: Completion/Builtins/_zmodload, + Doc/Makefile.in, Test/.distfiles: missing stuff in 3.1.6-dev-15: + unused parameter in _zmodload, deleting too many files with clean + in Doc, 08traps.ztst wasn't in distribution list. + +2000-01-13 Peter Stephenson + + * pws: 9309: Completion/Core/_path_files, + Completion/Builtins/_zstyle: fixes for 9298: test for non-zero + $FIGNORE, zstyle completion for ignored-patterns. + + * Sven: 9306: Doc/Zsh/mod_zle.yo, Src/Zle/zle_thingy.c: allow + permanent (until next return) message with zle -M. + + * Sven: 9305: Src/Zle/compcore.c: sometimes failed to switch to + alternate match set. + 2000-01-12 Peter Stephenson * pws: Config/version.mk: 3.1.6-dev-15. - * pws: configure.in: use quoted '${VERSION}' in function directory - to be determined at compile time, avoids having to re-make - config.status. + * pws: 9301: configure.in: use quoted '${VERSION}' in function + directory to be determined at compile time, avoids having to + re-make config.status. * Sven: 9298: Completion/Core/_description, Completion/Core/_main_complete, Completion/Core/_path_files, diff --git a/Completion/User/.distfiles b/Completion/User/.distfiles index c7c7cd831..e42d00597 100644 --- a/Completion/User/.distfiles +++ b/Completion/User/.distfiles @@ -1,11 +1,10 @@ DISTFILES_SRC=' .distfiles _a2ps _archie _bison _bunzip2 _bzip2 _chown _compress _configure _cvs - _dd _dir_list _dirs _domains _dvi _find _finger _flex - _gcc _gdb _gprof _groups _gs _gunzip _gv _gzip - _hosts _ispell _killall _lp _lynx _mailboxes _make _man - _mh _mount _mutt _my_accounts _netscape _nslookup _other_accounts - _pack _patch _pbm _pdf _perl_basepods _perl_builtin_funcs + _dd _dir_list _dirs _domains _dvi _find _finger _flex _gcc _gdb _gprof + _groups _gs _gunzip _gv _gzip _hosts _ispell _killall _lp _lynx + _mailboxes _make _man _mh _mount _mutt _my_accounts _netscape _nslookup + _other_accounts _pack _patch _pbm _pdf _perl_basepods _perl_builtin_funcs _perl_modules _perldoc _ports _prcs _prompt _ps _pspdf _rcs _rlogin _sh _socket _ssh _strip _stty _su _sudo _tar _tar_archive _telnet _tex _tiff _uncompress _unpack _urls _use_lo _user_at_host _users _users_on diff --git a/Config/version.mk b/Config/version.mk index 658282923..e61c2316a 100644 --- a/Config/version.mk +++ b/Config/version.mk @@ -27,5 +27,5 @@ # This must also serve as a shell script, so do not add spaces around the # `=' signs. -VERSION=3.1.6-dev-15 -VERSION_DATE='January 12, 2000' +VERSION=3.1.6-dev-16 +VERSION_DATE='January 18, 2000' diff --git a/Doc/Makefile.in b/Doc/Makefile.in index bc9627b5f..eafbc2dd3 100644 --- a/Doc/Makefile.in +++ b/Doc/Makefile.in @@ -60,7 +60,7 @@ Zsh/mod_computil.yo \ Zsh/mod_deltochar.yo Zsh/mod_example.yo Zsh/mod_files.yo \ Zsh/mod_mapfile.yo Zsh/mod_mathfunc.yo Zsh/mod_parameter.yo Zsh/mod_sched.yo \ Zsh/mod_stat.yo Zsh/mod_zftp.yo Zsh/mod_zle.yo Zsh/mod_zleparameter.yo \ -Zsh/mod_zutil.yo Zsh/mod_zprof.yo Zsh/mod_zpty.yo +Zsh/mod_zutil.yo Zsh/mod_zprof.yo YODLSRC = zmacros.yo zman.yo ztexi.yo Zsh/arith.yo Zsh/builtins.yo \ Zsh/compat.yo Zsh/compctl.yo Zsh/compsys.yo Zsh/compwid.yo Zsh/cond.yo \ diff --git a/Doc/Zsh/.distfiles b/Doc/Zsh/.distfiles index fd1c27874..4bfa02dd6 100644 --- a/Doc/Zsh/.distfiles +++ b/Doc/Zsh/.distfiles @@ -7,7 +7,7 @@ DISTFILES_SRC=' mod_computil.yo mod_deltochar.yo mod_example.yo mod_files.yo mod_mapfile.yo mod_mathfunc.yo mod_parameter.yo mod_sched.yo mod_stat.yo mod_zftp.yo mod_zle.yo mod_zleparameter.yo mod_zutil.yo - mod_zprof.yo mod_zpty.yo + mod_zprof.yo modules.yo modmenu.yo manmodmenu.yo options.yo params.yo prompt.yo redirect.yo restricted.yo seealso.yo zftpsys.yo zle.yo diff --git a/Functions/Misc/.distfiles b/Functions/Misc/.distfiles index e4ae3940b..474c9cf74 100644 --- a/Functions/Misc/.distfiles +++ b/Functions/Misc/.distfiles @@ -1,6 +1,5 @@ DISTFILES_SRC=' .distfiles acx allopt cat cdmatch cdmatch2 checkmail colors cx harden mere multicomp - nslookup proto pushd randline run-help yp yu zed zless zls + nslookup proto pushd randline run-help yp yu zed zless zls zmv ' - diff --git a/Functions/Misc/nslookup b/Functions/Misc/nslookup index 499cabf5a..d59a5e66c 100644 --- a/Functions/Misc/nslookup +++ b/Functions/Misc/nslookup @@ -1,31 +1,34 @@ # Simple wrapper function for `nslookup'. With completion if you are using # the function based completion system. -setopt localoptions localtraps completealiases +setopt localoptions completealiases -local tmp line compcontext=nslookup curcontext=':nslookup' pmpt +local char line compcontext=nslookup pid -trap 'return 130' INT -trap 'zpty -d nslookup' EXIT +trap 'print -p exit;return' INT -pmpt=() -zstyle -s ':nslookup' prompt tmp && pmpt=(-p "$tmp") -zstyle -s ':nslookup' rprompt tmp && pmpt=("$pmpt[@]" -r "$tmp") -(( $#pmpt )) || pmpt=(-p '> ') +coproc command nslookup +pid=$! -zpty nslookup nslookup - -zpty -r nslookup line '*> ' -print -nr "$line" - -while line=''; vared -he "$pmpt[@]" line; do - print -s "$line" - [[ "$line" = exit ]] && break - - zpty -w nslookup "$line" - - zpty -r nslookup line '*> ' || break - print -nr "$line" +while read -pk 1 char; do + line="$line$char" + [[ "$line" = *' +> ' ]] && break +done +print -nr - "$line" + +line='' +while vared -p '> ' line; do + print -p "$line" + line='' + while read -pk 1 char; do + line="$line$char" + [[ "$line" = *' +> ' ]] && break + done + print -nr - "$line" + line='' done -zpty -w nslookup 'exit' +print -p exit +wait $pid diff --git a/Functions/Misc/zmv b/Functions/Misc/zmv new file mode 100644 index 000000000..2067c73c4 --- /dev/null +++ b/Functions/Misc/zmv @@ -0,0 +1,165 @@ +# function zmv { +# zmv, zcp, zln: +# +# Use zsh pattern matching to move, copy or link files, depending on +# the last two characters of the function name. The general syntax is +# zmv '' '' +# is a globbing pattern, so it should be quoted to prevent it from +# immediate expansion, while is a string that will be +# re-evaluated and hence may contain parameter substitutions, which should +# also be quoted. Each set of parentheses in (apart from those +# around glob qualifiers and globbing flags) may be referred to by a +# positional parameter in , i.e. the first (...) matched is +# given by $1, and so on. For example, +# zmv '([a-z])(*).txt' '${(U)1}$2.txt' +# renames algernon.txt to Algernon.txt, boris.txt to Boris.txt and so on. +# The original file matched can be referred to as $f in the second +# argument; accidental or deliberate use of other parameters is at owner's +# risk and is not covered by the (non-existent) guarantee. +# +# Any error --- a substitution resulted in an empty string, a +# substitution did not change the file name, two substitutions gave the +# same result, the destination was an existing regular file and -f was not +# given --- causes the entire function to abort without doing anything. +# +# Options: +# -f force overwriting of destination files. Not currently passed +# down to the mv/cp/ln command due to vagaries of implementations +# (but you can use -o-f to do that). +# -i interactive: show each line to be executed and ask the user whether +# to execute it. Y or y will execute it, anything else will skip it. +# Note that you just need to type one character. +# -n no execution: print what would happen, but don't do it. +# -q don't allow bare glob qualifiers in the filename pattern, see below. +# -s symbolic, passed down to ln; only works with zln or z?? -L. +# -v verbose: print line as it's being executed. +# -o +# will be split into words and passed down verbatim +# to the cp, ln or mv called to perform the work. It will probably +# begin with a `-'. +# -p +# Call instead of cp, ln or mv. Whatever it does, it should +# at least understand the form ' -- ', +# where and are filenames generated. +# -C +# -L +# -M Force cp, ln or mv, respectively, regardless of the name of the +# function. +# +# Bugs: +# Parenthesised expressions can be confused with glob qualifiers, for +# example a trailing '(*)' is treated as a glob qualifier. Use -q to +# turn off glob qualifiers, or (yuk) add a suitable dummy qualifier +# (e.g. `(.)') or dummy pattern (e.g. `(|)') at the end. +# +# The second argument is re-evaluated in order to expand the parameters, +# so quoting may be a bit haphazard. In particular, a double quote +# will need an extra level of quoting. +# +# The pattern is always treated as an extendedglob pattern. +# +# Unbugs: +# You don't need braces around the 1 in expressions like '$1t' as +# non-positional parameters may not start with a number, although +# paranoiacs like the author will probably put them there anyway. + +emulate -L zsh +setopt extendedglob + +local f g args match mbegin mend files action myname tmpf opt exec +local opt_f opt_i opt_n opt_q opt_s opt_M opt_C opt_L opt_o opt_p +local pat repl errstr +typeset -A from to +integer stat + +while getopts ":o:p:MCLfinqsv" opt; do + if [[ $opt = "?" ]]; then + print -P "%N: unrecognized option: -$OPTARG" >&2 + return 1 + fi + eval "opt_$opt=${OPTARG:--$opt}" +done +(( OPTIND > 1 )) && shift $(( OPTIND - 1 )) + +[[ -n $opt_q ]] && setopt nobareglobqual +[[ -n $opt_M ]] && action=mv +[[ -n $opt_C ]] && action=cp +[[ -n $opt_L ]] && action=ln +[[ -n $opt_p ]] && action=$opt_p + +if (( $# != 2 )); then + print -P "Usage: %N oldpattern newpattern + e.g. %N '(*).lis' '\$1.txt'" >&2 + return 1 +fi + +pat=$1 +repl=$2 + +if [[ -z $action ]]; then + # We can't necessarily get the name of the function directly, because + # of no_function_argzero stupidity. + tmpf=${TMPPREFIX}zmv$$ + print -P %N >$tmpf + myname=$(<$tmpf) + rm -f $tmpf + + action=$myname[-2,-1] + + if [[ $action != (cp|mv|ln) ]]; then + print "Action $action not recognised: must be cp, mv or ln." >&2 + return 1 + fi +fi + + +if [[ -n $opt_s && $action != ln ]]; then + print -P "%N: invalid option: -s" >&2 + return 1 +fi + +files=(${~pat}) + +if [[ -o bareglobqual && $pat = (#b)(*)\([^\)\|\~]##\) ]]; then + # strip off qualifiers for use as ordinary pattern + pat=$match[1] +fi + +errs=() + +for f in $files; do + [[ -e $f && $f = (#b)${~pat} ]] || continue + set -- $match + eval g=\"$repl\" + if [[ -z $g ]]; then + errs=($errs "$f expanded to empty string") + elif [[ $f = $g ]]; then + errs=($errs "$f not altered by substitution") + elif [[ -n $from[$g] && ! -d $g ]]; then + errs=($errs "$f and $from[$g] both map to $g") + elif [[ -f $g && -z $opt_f ]]; then + errs=($errs "file exists: $g") + fi + from[$g]=$f + to[$f]=$g +done + +if (( $#errs )); then + print -P "%N: error(s) in substitution:" >&2 + print -l $errs >&2 + return 1 +fi + +for f in $files; do + exec=($action ${=opt_o} $opt_s -- $f $to[$f]) + [[ -n $opt_i$opt_n$opt_v ]] && print -- $exec + if [[ -n $opt_i ]]; then + read -q 'opt?Execute? ' || continue + fi + if [[ -z $opt_n ]]; then + $exec || stat=1 + fi +done + +return $stat +# } diff --git a/Src/Modules/.distfiles b/Src/Modules/.distfiles index 730aeeecc..5bb3f6ef6 100644 --- a/Src/Modules/.distfiles +++ b/Src/Modules/.distfiles @@ -9,6 +9,6 @@ DISTFILES_SRC=' parameter.mdd parameter.c stat.mdd stat.c zftp.mdd zftp.c + zprof.mdd zprof.c zutil.mdd zutil.c - zpty.mdd zpty.c ' diff --git a/Src/builtin.c b/Src/builtin.c index 8d56dd4d2..a373d9dd2 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -3219,7 +3219,6 @@ zexit(int val, int from_signal) } if (sigtrapped[SIGEXIT]) dotrap(SIGEXIT); - runhookdef(EXITHOOK, NULL); if (mypid != getpid()) _exit(val); else diff --git a/Src/exec.c b/Src/exec.c index 6c7892318..ac0288be0 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -2519,7 +2519,8 @@ getoutput(char *cmd, int qt) wc_code(pc[2]) == WC_PIPE && WC_PIPE_TYPE(pc[2]) == WC_PIPE_END && wc_code(pc[3]) == WC_REDIR && WC_REDIR_TYPE(pc[3]) == READ && !pc[4] && - wc_code(pc[6]) == WC_SIMPLE && !WC_SIMPLE_ARGC(pc[6])) { + wc_code(pc[6]) == WC_SIMPLE && !WC_SIMPLE_ARGC(pc[6]) && + wc_code(pc[7]) == WC_END) { /* $(< word) */ int stream; char *s = dupstring(ecrawstr(prog, pc + 5)); diff --git a/Src/glob.c b/Src/glob.c index fc2c64cfd..73a752536 100644 --- a/Src/glob.c +++ b/Src/glob.c @@ -41,13 +41,13 @@ typedef struct gmatch *Gmatch; struct gmatch { - off_t size ALIGN64; - off_t _size ALIGN64; char *name; + off_t size ALIGN64; long atime; long mtime; long ctime; long links; + off_t _size ALIGN64; long _atime; long _mtime; long _ctime; @@ -102,10 +102,10 @@ typedef struct stat *Statptr; /* This makes the Ultrix compiler happy. Go figu typedef int (*TestMatchFunc) _((char *, struct stat *, off_t, char *)); struct qual { - off_t data ALIGN64; /* Argument passed to function */ struct qual *next; /* Next qualifier, must match */ struct qual *or; /* Alternative set of qualifiers to match */ TestMatchFunc func; /* Function to call to test match */ + off_t data ALIGN64; /* Argument passed to function */ int sense; /* Whether asserting or negating */ int amc; /* Flag for which time to test (a, m, c) */ int range; /* Whether to test <, > or = (as per signum) */ diff --git a/Src/init.c b/Src/init.c index 4aa268f0d..20e996fdd 100644 --- a/Src/init.c +++ b/Src/init.c @@ -89,11 +89,6 @@ mod_export int (*getkeyptr) _((int)); mod_export int alloc_stackp; #endif -/**/ -mod_export struct hookdef zshhooks[] = { - HOOKDEF("exit", NULL, HOOKF_ALL), -}; - /* keep executing lists until EOF found */ /**/ @@ -565,8 +560,6 @@ setupvals(void) # endif #endif - addhookdefs(argzero, zshhooks, sizeof(zshhooks)/sizeof(*zshhooks)); - init_eprog(); getkeyptr = NULL; diff --git a/Src/zsh.h b/Src/zsh.h index 54141d2b7..15b01a0db 100644 --- a/Src/zsh.h +++ b/Src/zsh.h @@ -1649,9 +1649,3 @@ typedef unsigned char * (*ZleReadFn) _((char *, char *, int)); /***************************************/ #define mod_export - -/***************************************/ -/* Hooks in core. */ -/***************************************/ - -#define EXITHOOK (zshhooks + 0) -- cgit 1.4.1