From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16910 invoked from network); 11 Jul 2008 08:32:17 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 11 Jul 2008 08:32:17 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 91968 invoked from network); 11 Jul 2008 08:32:13 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 11 Jul 2008 08:32:13 -0000 Received: (qmail 28057 invoked by alias); 11 Jul 2008 08:32:09 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 25276 Received: (qmail 28041 invoked from network); 11 Jul 2008 08:32:08 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 11 Jul 2008 08:32:08 -0000 Received: from mx.spodhuis.org (redoubt.spodhuis.org [193.202.115.177]) by bifrost.dotsrc.org (Postfix) with ESMTPS id AB15180524FA for ; Fri, 11 Jul 2008 10:32:03 +0200 (CEST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=d200803; d=spodhuis.org; h=Received:Date:From:To:Subject:Message-ID:Mail-Followup-To:MIME-Version:Content-Type:Content-Disposition; b=CjkMMxjvwOQ0FkV9inrjDJ7NPKYNKnMzUJCbIZkvmYiArpOwZpONrUD77kZ2LESaDoWoYUO/4coEb7KFEGw6rADdR98f1l66FbgmCG/YNfta5BB3SVTzaox3Mr7EPv+EvSh+vg0KI+p3BcFNtF6m5UWivR4x8faju3g7JD3d1mE=; Received: by smtp.spodhuis.org with local id 1KHE2t-0007Eh-Hu; Fri, 11 Jul 2008 08:32:03 +0000 Date: Fri, 11 Jul 2008 01:32:03 -0700 From: Phil Pennock To: zsh-workers@sunsite.dk Subject: PATCH: ksh_autoload safety cleanup Message-ID: <20080711083203.GA51766@redoubt.spodhuis.org> Mail-Followup-To: zsh-workers@sunsite.dk MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Virus-Scanned: ClamAV 0.92.1/7689/Fri Jul 11 07:09:27 2008 on bifrost X-Virus-Status: Clean Various places weren't using -z for autoload -U to load in zsh-style, even if the user has ksh_autoload set. Not an option I normally use, but since the option is there we should be resilient against it. 26 files changed. In fixing this, I left alone files with "emulate" in them, assuming that they're setting emulate zsh and assuming that they're doing it in time to catch the autoload. I did choose to change the example loading invocations to include -z though, even in cases of the file itself using emulate. I don't guarantee to have caught all of those. In cases where "autoload +X" is used, I leave it alone in the expectation that the original autoload command correctly declared -z if needed. There's a problem in that "emulate zsh" followed by "autoload" doesn't preserve the zsh-nature of the autoload file for the time when it's eventually used, which means that my autoload +X exemption isn't good enough but I don't know a way to solve this in the function level. Proof of problem: ...% zsh -f % emulate zsh % autoload is-at-least % setopt ksh_autoload % is-at-least 4.3.6 zsh: is-at-least: function not defined by file The zshbuiltins man-page notes (under typeset -f): ----------------------------8< cut here >8------------------------------ The -k and -z flags make the function be loaded using ksh-style or zsh-style autoloading respectively. If neither is given, the set- ting of the KSH_AUTOLOAD option determines how the func- tion is loaded. ----------------------------8< cut here >8------------------------------ I'd naively interpret that to mean that the ksh_autoload setting at the time of the autoload/typeset determines it, rather than the value at the time the function is eventually loaded. I'm not convinced that the current behaviour is correct and am wondering if the -k/-z should be implicitly provided instead. Is there any situation where declaring autoload in one mode and then loading later in the other mode is likely to be correct and/or desired? Afterwards, grep -L '^[^#]*emulate' $(egrep -lr '(^autoload|[^#]autoload) ([^-]|-[^z ]* )' .) includes source files, documentation, completion functions relating to autoload and friends, test files, newuser, the demo zshrc and standalone scripts. And a very few false positives. Regards, -Phil ----------------------------8< cut here >8------------------------------ Index: Completion/Darwin/Type/_retrieve_mac_apps =================================================================== RCS file: /home/cvsroot/zsh/Completion/Darwin/Type/_retrieve_mac_apps,v retrieving revision 1.2 diff -p -u -r1.2 _retrieve_mac_apps --- Completion/Darwin/Type/_retrieve_mac_apps 13 May 2005 17:49:01 -0000 1.2 +++ Completion/Darwin/Type/_retrieve_mac_apps 11 Jul 2008 08:03:34 -0000 @@ -47,7 +47,7 @@ _mac_apps_old_retrieve () { # Get single file applications if ! zstyle -t ":completion:${curcontext}:commands" ignore-single; then - autoload -U zargs + autoload -Uz zargs local app_cand nargs envvars app_cand=( ${^app_dir}^*.[a-z]#/..namedfork/rsrc(.UrN,.RN^U) ) envvars="$(builtin typeset -x)" Index: Completion/Unix/Command/_baz =================================================================== RCS file: /home/cvsroot/zsh/Completion/Unix/Command/_baz,v retrieving revision 1.11 diff -p -u -r1.11 _baz --- Completion/Unix/Command/_baz 15 Aug 2006 05:04:58 -0000 1.11 +++ Completion/Unix/Command/_baz 11 Jul 2008 08:14:26 -0000 @@ -1,6 +1,6 @@ #compdef baz -autoload is-at-least +autoload -z is-at-least local BAZ=$words[1] local baz_version local hide_short Index: Completion/Unix/Command/_darcs =================================================================== RCS file: /home/cvsroot/zsh/Completion/Unix/Command/_darcs,v retrieving revision 1.6 diff -p -u -r1.6 _darcs --- Completion/Unix/Command/_darcs 27 Nov 2006 04:08:41 -0000 1.6 +++ Completion/Unix/Command/_darcs 11 Jul 2008 08:14:31 -0000 @@ -6,7 +6,7 @@ setopt EXTENDED_GLOB local DARCS=$words[1] # test whether to hide short options from completion -autoload is-at-least +autoload -z is-at-least local hide_short if zstyle -s ":completion:${curcontext}" hide-shortopts hide_short; then case $hide_short in Index: Completion/Unix/Command/_tar =================================================================== RCS file: /home/cvsroot/zsh/Completion/Unix/Command/_tar,v retrieving revision 1.7 diff -p -u -r1.7 _tar --- Completion/Unix/Command/_tar 10 Oct 2006 22:38:40 -0000 1.7 +++ Completion/Unix/Command/_tar 11 Jul 2008 08:14:35 -0000 @@ -24,7 +24,7 @@ local _tar_cmd tf tmp tmpb del index if _pick_variant gnu=GNU unix --version; then case "$($service --version)" in (tar \(GNU tar\) (#b)([0-9.-]##)*) - autoload is-at-least + autoload -z is-at-least is-at-least 1.14.91 "$match[1]" || _cmd_variant[$service]="gnu-old" ;; esac Index: Completion/Unix/Command/_tla =================================================================== RCS file: /home/cvsroot/zsh/Completion/Unix/Command/_tla,v retrieving revision 1.8 diff -p -u -r1.8 _tla --- Completion/Unix/Command/_tla 22 Aug 2006 21:54:00 -0000 1.8 +++ Completion/Unix/Command/_tla 11 Jul 2008 08:14:38 -0000 @@ -1,6 +1,6 @@ #compdef tla -autoload is-at-least +autoload -z is-at-least local TLA=$words[1] local tla_version local hide_short Index: Completion/Zsh/Command/_zftp =================================================================== RCS file: /home/cvsroot/zsh/Completion/Zsh/Command/_zftp,v retrieving revision 1.2 diff -p -u -r1.2 _zftp --- Completion/Zsh/Command/_zftp 14 Jun 2001 19:58:28 -0000 1.2 +++ Completion/Zsh/Command/_zftp 11 Jul 2008 08:05:01 -0000 @@ -28,13 +28,13 @@ fi case $subcom in *(cd|ls|dir)) # complete remote directories - [[ -z ${functions[zfcd_match]} ]] && autoload -U zfcd_match + [[ -z ${functions[zfcd_match]} ]] && autoload -Uz zfcd_match _tags directories && zfcd_match $PREFIX $SUFFIX ;; *(get(|at)|gcp|delete|remote)) # complete remote files - [[ -z ${functions[zfget_match]} ]] && autoload -U zfget_match + [[ -z ${functions[zfget_match]} ]] && autoload -Uz zfget_match _tags files && zfget_match $PREFIX $SUFFIX ;; Index: Functions/Misc/sticky-note =================================================================== RCS file: /home/cvsroot/zsh/Functions/Misc/sticky-note,v retrieving revision 1.4 diff -p -u -r1.4 sticky-note --- Functions/Misc/sticky-note 22 Feb 2008 02:56:14 -0000 1.4 +++ Functions/Misc/sticky-note 11 Jul 2008 07:54:25 -0000 @@ -4,7 +4,7 @@ # $HOME/.zsticky). The number of notes stored is STICKYSIZE (1000). # # Load this file as a function: -# autoload -U sticky-note +# autoload -Uz sticky-note # # It may then be bound as a widget: # zle -N sticky-note Index: Functions/Misc/tetris =================================================================== RCS file: /home/cvsroot/zsh/Functions/Misc/tetris,v retrieving revision 1.1 diff -p -u -r1.1 tetris --- Functions/Misc/tetris 21 Sep 2001 02:40:38 -0000 1.1 +++ Functions/Misc/tetris 11 Jul 2008 07:57:19 -0000 @@ -1,7 +1,7 @@ # Someone once accused zsh of not being as complete as Emacs, because it # lacks Tetris and an adventure game. # -# autoload -U tetris +# autoload -Uz tetris # zle -N tetris # bindkey '...' tetris Index: Functions/Misc/xtermctl =================================================================== RCS file: /home/cvsroot/zsh/Functions/Misc/xtermctl,v retrieving revision 1.2 diff -p -u -r1.2 xtermctl --- Functions/Misc/xtermctl 18 Feb 2008 03:30:22 -0000 1.2 +++ Functions/Misc/xtermctl 11 Jul 2008 07:54:09 -0000 @@ -1,7 +1,7 @@ # Put standard xterm/dtterm window control codes in shell parameters for # easy use. Note that some terminals do not support all combinations. -# autoload -U xtermctl ; xtermctl +# autoload -Uz xtermctl ; xtermctl # xtermctl --explain # Run once to set up; implements two functions: Index: Functions/Misc/zed =================================================================== RCS file: /home/cvsroot/zsh/Functions/Misc/zed,v retrieving revision 1.9 diff -p -u -r1.9 zed --- Functions/Misc/zed 10 Aug 2004 23:34:58 -0000 1.9 +++ Functions/Misc/zed 11 Jul 2008 07:57:06 -0000 @@ -56,7 +56,7 @@ if (( bind )) || ! bindkey -M zed >&/dev # Make zed-set-file-name available. # Assume it's in fpath; there's no error at this point if it isn't - autoload -U zed-set-file-name + autoload -Uz zed-set-file-name zle -N zed-set-file-name fi if (( bind )) || ! bindkey -M zed-vicmd >&/dev/null; then @@ -74,7 +74,7 @@ if ((fun)) then var="$(functions $1)" # If function is undefined but autoloadable, load it if [[ $var = *\#\ undefined* ]] then - var="$(autoload +X $1; functions $1)" + ar="$(autoload +X $1; functions $1)" elif [[ -z $var ]] then var="$1() { }" Index: Functions/Prompts/prompt_bigfade_setup =================================================================== RCS file: /home/cvsroot/zsh/Functions/Prompts/prompt_bigfade_setup,v retrieving revision 1.4 diff -p -u -r1.4 prompt_bigfade_setup --- Functions/Prompts/prompt_bigfade_setup 17 May 2008 22:42:17 -0000 1.4 +++ Functions/Prompts/prompt_bigfade_setup 11 Jul 2008 08:01:05 -0000 @@ -28,7 +28,7 @@ prompt_bigfade_setup () { local cwd=${4:-'yellow'} local -A schars - autoload -U prompt_special_chars + autoload -Uz prompt_special_chars prompt_special_chars PS1="%B%F{$fadebar}$schars[333]$schars[262]$schars[261]$schars[260]%B%F{$userhost}%K{$fadebar}%n@%m%b%k%f%F{$fadebar}%K{black}$schars[260]$schars[261]$schars[262]$schars[333]%b%f%k%F{$fadebar}%K{black}$schars[333]$schars[262]$schars[261]$schars[260]%B%F{$date}%K{black} %D{%a %b %d} %D{%I:%M:%S%P}$prompt_newline%B%F{$cwd}%K{black}$PWD>%b%f%k " Index: Functions/Prompts/prompt_elite2_setup =================================================================== RCS file: /home/cvsroot/zsh/Functions/Prompts/prompt_elite2_setup,v retrieving revision 1.5 diff -p -u -r1.5 prompt_elite2_setup --- Functions/Prompts/prompt_elite2_setup 17 May 2008 22:42:17 -0000 1.5 +++ Functions/Prompts/prompt_elite2_setup 11 Jul 2008 08:01:10 -0000 @@ -22,7 +22,7 @@ prompt_elite2_setup () { local parens_col=${2:-$text_col} local -A schars - autoload -U prompt_special_chars + autoload -Uz prompt_special_chars prompt_special_chars local text="%b%F{$text_col}" Index: Functions/Prompts/prompt_elite_setup =================================================================== RCS file: /home/cvsroot/zsh/Functions/Prompts/prompt_elite_setup,v retrieving revision 1.4 diff -p -u -r1.4 prompt_elite_setup --- Functions/Prompts/prompt_elite_setup 17 May 2008 22:42:17 -0000 1.4 +++ Functions/Prompts/prompt_elite_setup 11 Jul 2008 08:01:15 -0000 @@ -22,7 +22,7 @@ prompt_elite_setup () { local punctuation=${2:-'blue'} local -A schars - autoload -U prompt_special_chars + autoload -Uz prompt_special_chars prompt_special_chars PS1="%F{$text}$schars[332]$schars[304]%F{$punctuation}(%F{$text}%n%F{$punctuation}@%F{$text}%m%F{$punctuation})%F{$text}-%F{$punctuation}(%F{$text}%D{%I:%M%P}%F{$punctuation}-:-%F{$text}%D{%m}%F{$punctuation}%F{$text}/%D{%d}%F{$punctuation})%F{$text}$schars[304]-%F{$punctuation}$schars[371]%F{$text}-$schars[371]$schars[371]%F{$punctuation}$schars[372]$prompt_newline%F{$text}$schars[300]$schars[304]%F{$punctuation}(%F{$text}%1~%F{$punctuation})%F{$text}$schars[304]$schars[371]%F{$punctuation}$schars[372]%f" Index: Functions/Prompts/prompt_fade_setup =================================================================== RCS file: /home/cvsroot/zsh/Functions/Prompts/prompt_fade_setup,v retrieving revision 1.4 diff -p -u -r1.4 prompt_fade_setup --- Functions/Prompts/prompt_fade_setup 17 May 2008 22:42:17 -0000 1.4 +++ Functions/Prompts/prompt_fade_setup 11 Jul 2008 08:01:23 -0000 @@ -28,7 +28,7 @@ prompt_fade_setup () { local date=${3:-'white'} local -A schars - autoload -U prompt_special_chars + autoload -Uz prompt_special_chars prompt_special_chars PS1="%F{$fadebar_cwd}%B%K{$fadebar_cwd}$schars[333]$schars[262]$schars[261]$schars[260]%F{$userhost}%K{$fadebar_cwd}%B%n@%m%b%F{$fadebar_cwd}%K{black}$schars[333]$schars[262]$schars[261]$schars[260]%F{$date}%K{black}%B %D{%a %b %d} %D{%I:%M:%S%P} $prompt_newline%F{fadebar_cwd}%K{black}%B%~/%b%k%f " Index: Functions/Prompts/prompt_fire_setup =================================================================== RCS file: /home/cvsroot/zsh/Functions/Prompts/prompt_fire_setup,v retrieving revision 1.4 diff -p -u -r1.4 prompt_fire_setup --- Functions/Prompts/prompt_fire_setup 17 May 2008 22:42:17 -0000 1.4 +++ Functions/Prompts/prompt_fire_setup 11 Jul 2008 08:01:28 -0000 @@ -30,7 +30,7 @@ prompt_fire_setup () { local cwd=${6:-'yellow'} local -a schars - autoload -U prompt_special_chars + autoload -Uz prompt_special_chars prompt_special_chars local GRAD1="%{$schars[333]$schars[262]$schars[261]$schars[260]%}" Index: Functions/Prompts/promptinit =================================================================== RCS file: /home/cvsroot/zsh/Functions/Prompts/promptinit,v retrieving revision 1.8 diff -p -u -r1.8 promptinit --- Functions/Prompts/promptinit 17 May 2008 22:42:17 -0000 1.8 +++ Functions/Prompts/promptinit 11 Jul 2008 08:02:28 -0000 @@ -2,7 +2,7 @@ ## zsh prompt themes extension ## by Adam Spiers ## -## Load with `autoload -U promptinit; promptinit'. +## Load with `autoload -Uz promptinit; promptinit'. ## Type `prompt -h' for help. ## Index: Functions/Zle/edit-command-line =================================================================== RCS file: /home/cvsroot/zsh/Functions/Zle/edit-command-line,v retrieving revision 1.5 diff -p -u -r1.5 edit-command-line --- Functions/Zle/edit-command-line 12 Nov 2002 12:09:51 -0000 1.5 +++ Functions/Zle/edit-command-line 11 Jul 2008 08:25:25 -0000 @@ -1,6 +1,6 @@ # Edit the command line using your usual editor. # Binding this to 'v' in the vi command mode map, -# autoload edit-command-line +# autoload -z edit-command-line # zle -N edit-command-line # bindkey -M vicmd v edit-command-line # will give ksh-like behaviour for that key, Index: Functions/Zle/history-beginning-search-menu =================================================================== RCS file: /home/cvsroot/zsh/Functions/Zle/history-beginning-search-menu,v retrieving revision 1.5 diff -p -u -r1.5 history-beginning-search-menu --- Functions/Zle/history-beginning-search-menu 2 Aug 2006 09:59:23 -0000 1.5 +++ Functions/Zle/history-beginning-search-menu 11 Jul 2008 08:02:02 -0000 @@ -3,7 +3,7 @@ # the entire history is searched. # # Configuration: -# autoload -U history-beginning-search-menu +# autoload -Uz history-beginning-search-menu # zle -N history-beginning-search-menu # bindkey '\eP' history-beginning-search-menu # Index: Functions/Zle/incarg =================================================================== RCS file: /home/cvsroot/zsh/Functions/Zle/incarg,v retrieving revision 1.1.1.1 diff -p -u -r1.1.1.1 incarg --- Functions/Zle/incarg 13 Sep 1999 16:32:31 -0000 1.1.1.1 +++ Functions/Zle/incarg 11 Jul 2008 08:02:08 -0000 @@ -1,6 +1,6 @@ # Shell function to increment an integer either under the cursor or just # to the left of it. Use -# autoload -U incarg +# autoload -Uz incarg # zle -N incarg # bindkey "..." incarg # to define it. For example, Index: Functions/Zle/modify-current-argument =================================================================== RCS file: /home/cvsroot/zsh/Functions/Zle/modify-current-argument,v retrieving revision 1.2 diff -p -u -r1.2 modify-current-argument --- Functions/Zle/modify-current-argument 24 Jun 2008 16:09:28 -0000 1.2 +++ Functions/Zle/modify-current-argument 11 Jul 2008 08:00:08 -0000 @@ -16,7 +16,7 @@ setopt localoptions noksharrays multibyt local -a reply integer REPLY REPLY2 -autoload -U split-shell-arguments +autoload -Uz split-shell-arguments split-shell-arguments # Can't do this unless there's some text under or left of us. Index: Functions/Zle/narrow-to-region-invisible =================================================================== RCS file: /home/cvsroot/zsh/Functions/Zle/narrow-to-region-invisible,v retrieving revision 1.1 diff -p -u -r1.1 narrow-to-region-invisible --- Functions/Zle/narrow-to-region-invisible 4 Jul 2002 13:53:49 -0000 1.1 +++ Functions/Zle/narrow-to-region-invisible 11 Jul 2008 08:00:19 -0000 @@ -1,5 +1,5 @@ # As narrow-to-region, but replaces the text outside the editable region # with `...' if it was non-empty. Can be used directly as a widget. -autoload -U narrow-to-region +autoload -Uz narrow-to-region narrow-to-region -p '...' -P '...' -n Index: Functions/Zle/predict-on =================================================================== RCS file: /home/cvsroot/zsh/Functions/Zle/predict-on,v retrieving revision 1.5 diff -p -u -r1.5 predict-on --- Functions/Zle/predict-on 22 Jun 2004 07:10:35 -0000 1.5 +++ Functions/Zle/predict-on 11 Jul 2008 08:00:34 -0000 @@ -15,7 +15,7 @@ # with RETURN, without needing to move the cursor to the end first. # # To use it: -# autoload -U predict-on +# autoload -Uz predict-on # zle -N predict-on # zle -N predict-off # bindkey '...' predict-on Index: Functions/Zle/quote-and-complete-word =================================================================== RCS file: /home/cvsroot/zsh/Functions/Zle/quote-and-complete-word,v retrieving revision 1.1 diff -p -u -r1.1 quote-and-complete-word --- Functions/Zle/quote-and-complete-word 27 Oct 2003 01:50:47 -0000 1.1 +++ Functions/Zle/quote-and-complete-word 11 Jul 2008 08:00:46 -0000 @@ -5,7 +5,7 @@ # normal completion fails, the quotes are removed again. # # To use it: -# autoload -U quote-and-complete-word +# autoload -Uz quote-and-complete-word # zle -N quote-and-complete-word # bindkey '\t' quote-and-complete-word # Index: Functions/Zle/transpose-words-match =================================================================== RCS file: /home/cvsroot/zsh/Functions/Zle/transpose-words-match,v retrieving revision 1.3 diff -p -u -r1.3 transpose-words-match --- Functions/Zle/transpose-words-match 25 Apr 2003 11:19:10 -0000 1.3 +++ Functions/Zle/transpose-words-match 11 Jul 2008 08:29:09 -0000 @@ -11,7 +11,7 @@ # on X would be turned into `barXfoo' with the cursor still on the X, # regardless of what the character X is. -autoload match-words-by-style +autoload -z match-words-by-style local curcontext=":zle:$WIDGET" skip local -a matched_words Index: Functions/Zle/url-quote-magic =================================================================== RCS file: /home/cvsroot/zsh/Functions/Zle/url-quote-magic,v retrieving revision 1.2 diff -p -u -r1.2 url-quote-magic --- Functions/Zle/url-quote-magic 17 Jun 2006 17:21:15 -0000 1.2 +++ Functions/Zle/url-quote-magic 11 Jul 2008 08:00:56 -0000 @@ -5,7 +5,7 @@ # the input character. # Setup: -# autoload -U url-quote-magic +# autoload -Uz url-quote-magic # zle -N self-insert url-quote-magic # A number of zstyles may be set to control the quoting behavior. Index: StartupFiles/zshrc =================================================================== RCS file: /home/cvsroot/zsh/StartupFiles/zshrc,v retrieving revision 1.3 diff -p -u -r1.3 zshrc --- StartupFiles/zshrc 9 May 2001 16:57:31 -0000 1.3 +++ StartupFiles/zshrc 11 Jul 2008 07:53:24 -0000 @@ -117,7 +117,7 @@ bindkey '^I' complete-word # complete on # Setup new style completion system. To see examples of the old style (compctl # based) programmable completion, check Misc/compctl-examples in the zsh # distribution. -autoload -U compinit +autoload -Uz compinit compinit # Completion Styles