diff options
-rw-r--r-- | ChangeLog | 26 | ||||
-rw-r--r-- | Completion/Unix/Command/_git | 2 | ||||
-rw-r--r-- | Completion/Unix/Type/_baudrates | 5 | ||||
-rw-r--r-- | Completion/compdump | 6 | ||||
-rw-r--r-- | Completion/compinit | 4 | ||||
-rw-r--r-- | Etc/FAQ.yo | 32 | ||||
-rw-r--r-- | Functions/Misc/zmv | 6 | ||||
-rw-r--r-- | Src/Modules/zftp.c | 1 | ||||
-rw-r--r-- | Src/builtin.c | 5 |
9 files changed, 73 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog index d3980ecfe..455cf38c3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,29 @@ +2024-06-13 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp> + + * 52951: Src/builtin.c: make sure to close memstream for 'print -v' + +2024-06-08 Mikael Magnusson <mikachu@gmail.com> + + * 52946: Completion/compdump, Completion/compinit: Revert 52768 + +2024-05-24 Bart Schaefer <schaefer@zsh.org> + + * users/29882: Etc/FAQ.yo: Explain $RANDOM predictability + + * 52910: Functions/Misc/zmv: Improve handling of **/ patterns + + * 52904: Completion/Unix/Command/_git: Improve quoting of paths + passed via _call_program to "git ls-files" + +2024-05-20 Mikael Magnusson <mikachu@gmail.com> + + * 52895: Completion/Unix/Type/_baudrates: Partial revert of + 44274 which broke _baudrates + +2024-05-10 Peter Stephenson <p.stephenson@samsung.com> + + * 52924: Src/Modules/zftp.c: NULL zfsessions after free. + 2024-05-08 Peter Stephenson <p.stephenson@samsung.com> * 52915: Doc/Zsh/cond.yo: be explicit about behaviour of globbing diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index 7370aaead..22b945e38 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -7531,7 +7531,7 @@ __git_files () { # First allow ls-files to pattern-match in case of remote repository. Use the # icase pathspec magic word to ensure that we support case-insensitive path # completion for users with the appropriate matcher configuration - files=(${(0)"$(_call_program files git ls-files -z --exclude-standard ${(q)opts} -- ${(q)${pref:+:\(icase\)$pref\*}:-.} 2>/dev/null)"}) + files=(${(0)"$(_call_program files git ls-files -z --exclude-standard ${(q)opts} -- ${(q)${pref:+:\(icase\)${(qq)pref}\*}:-.} 2>/dev/null)"}) __git_command_successful $pipestatus || return # If ls-files succeeded but returned nothing, try again with no pattern. Note diff --git a/Completion/Unix/Type/_baudrates b/Completion/Unix/Type/_baudrates index a9d7fe541..416a4919f 100644 --- a/Completion/Unix/Type/_baudrates +++ b/Completion/Unix/Type/_baudrates @@ -72,6 +72,7 @@ if (( ${+opts[-f]} )); then done fi -# -1 removes dupes (which there shouldn't be) -_description -1 -o numeric baud-rates expl 'baud rate' +# -1V removes dupes (which there shouldn't be) and otherwise leaves the +# order in the $rates array intact. +_description -1V baud-rates expl 'baud rate' compadd "${argv[@]}" "$expl[@]" -- "${rates[@]}" diff --git a/Completion/compdump b/Completion/compdump index 5af5174f1..6daf92f9f 100644 --- a/Completion/compdump +++ b/Completion/compdump @@ -113,7 +113,7 @@ integer _i=5 print -n autoload -Uz >& $_d_fd while (( $#_d_als )); do if (( ! $+_compautos[$_d_als[1]] )); then - print -rn " ${(q-)_d_als[1]}" + print -n " $_d_als[1]" if (( ! --_i && $#_d_als > 1 )); then _i=5 print -n ' \\\n ' @@ -126,13 +126,13 @@ print >& $_d_fd local _c for _c in "${(ok@)_compautos}"; do - print -r "autoload -Uz ${(q-)_compautos[$_c]} $_c" >& $_d_fd + print "autoload -Uz $_compautos[$_c] $_c" >& $_d_fd done print >& $_d_fd print "typeset -gUa _comp_assocs" >& $_d_fd -print -r "_comp_assocs=( ${(qq)_comp_assocs} )" >& $_d_fd +print "_comp_assocs=( ${(qq)_comp_assocs} )" >& $_d_fd exec {_d_fd}>&- mv -f $_d_file ${_d_file%.$HOST.$$} diff --git a/Completion/compinit b/Completion/compinit index 51e9d88b8..5cb527fac 100644 --- a/Completion/compinit +++ b/Completion/compinit @@ -301,7 +301,7 @@ compdef() { if [[ -z "$eval" ]] && [[ "$1" = *\=* ]]; then while (( $# )); do if [[ "$1" = *\=* ]]; then - cmd="${(q)${1%%\=*}}" + cmd="${1%%\=*}" svc="${1#*\=}" func="$_comps[${_services[(r)$svc]:-$svc}]" [[ -n ${_services[$svc]} ]] && @@ -412,7 +412,7 @@ compdef() { svc= fi if [[ -z "$new" || -z "${_comps[$1]}" ]]; then - _comps[$cmd]="${(q)func}" + _comps[$cmd]="$func" [[ -n "$svc" ]] && _services[$cmd]="${1#*\=}" fi ;; diff --git a/Etc/FAQ.yo b/Etc/FAQ.yo index 4e11637ea..2c83fe7fa 100644 --- a/Etc/FAQ.yo +++ b/Etc/FAQ.yo @@ -137,6 +137,7 @@ Chapter 3: How to get various things to work 3.28. How do I edit the input buffer in $EDITOR? 3.29. Why does `which' output for missing commands go to stdout? 3.30. Why doesn't the expansion mytt(*.{tex,aux,pdf}) do what I expect? +3.31. Why does mytt($RANDOM) return the same number more than once? Chapter 4: The mysteries of completion 4.1. What is completion? @@ -2219,6 +2220,37 @@ sect(Why doesn't the expansion mytt(*.{tex,aux,pdf}) do what I expect?) This is harder for the user to remember but easier for the shell to parse! +sect(Why does mytt($RANDOM) return the same number more than once?) + + As tt(zshparam(1)) says: + verb( + The values of RANDOM form an intentionally-repeatable + pseudo-random sequence; subshells that reference RANDOM + will result in identical pseudo-random values unless the + value of RANDOM is referenced or seeded in the parent shell + in between subshell invocations. + ) + + You can use a function, including an anonymous function, to always + evaluate mytt($RANDOM) in the parent shell. This example illustrates + the difference: + verb( + for i in {1..10}; do + echo subshell: $(echo $RANDOM) $RANDOM + () { echo parent: $(echo $1) $2 } $RANDOM $RANDOM; + done + ) + + Remember that for a pipe like mytt(A | B), zsh runs A in a subshell + and B in the current shell. This means that, for example: + verb( + for i in {1..10}; do + echo $RANDOM | tee + done + ) + also repeats the same value, because mytt($RANDOM) is evaluated in + the subshell and the parent sequence is left unchanged. + chapter(The mysteries of completion) sect(What is completion?) diff --git a/Functions/Misc/zmv b/Functions/Misc/zmv index 5c03e9ea1..2002af5a6 100644 --- a/Functions/Misc/zmv +++ b/Functions/Misc/zmv @@ -249,13 +249,13 @@ errs=() (( ${#files} )) || errs=( "no files matched \`$fpat'" ) for f in $files; do - if [[ $pat = (#b)(*)\(\*\*##/\)(*) ]]; then + if [[ $pat = (#b)(*)(\(\*\*##/\)|\*\*##/)(*) ]]; then # This looks like a recursive glob. This isn't good enough, - # because we should really enforce that $match[1] and $match[2] + # because we should really enforce that $match[1] and $match[3] # don't match slashes unless they were explicitly given. But # it's a start. It's fine for the classic case where (**/) is # at the start of the pattern. - pat="$match[1](*/|)$match[2]" + pat="$match[1](*/|)$match[3]" fi [[ -e $f && $f = (#b)${~pat} ]] || continue set -- "$match[@]" diff --git a/Src/Modules/zftp.c b/Src/Modules/zftp.c index 0c26828fd..b60e5bf31 100644 --- a/Src/Modules/zftp.c +++ b/Src/Modules/zftp.c @@ -3147,6 +3147,7 @@ zftp_cleanup(void) lastmsg = NULL; zfunsetparam("ZFTP_SESSION"); freelinklist(zfsessions, (FreeFunc) freesession); + zfsessions = NULL; zfree(zfstatusp, sizeof(int)*zfsesscnt); zfstatusp = NULL; } diff --git a/Src/builtin.c b/Src/builtin.c index 7bfb1ce1d..cd0ee7522 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -5455,9 +5455,8 @@ bin_print(char *name, char **args, Options ops, int func) } zwarnnam(name, "%s: invalid directive", start); if (*c) c[1] = save; - /* Why do we care about a clean close here? */ - if (!CLOSE_CLEANLY(fout)) - zwarnnam(name, "write error: %e", errno); + if (fout != stdout) + fclose(fout); #ifdef HAVE_OPEN_MEMSTREAM if (buf) free(buf); |