Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: fix _numbers for suffixes containing %
- X-seq: zsh-workers 52373
- From: Oliver Kiddle <opk@xxxxxxx>
- To: Zsh workers <zsh-workers@xxxxxxx>
- Subject: PATCH: fix _numbers for suffixes containing %
- Date: Tue, 05 Dec 2023 00:56:36 +0100
- Archived-at: <https://zsh.org/workers/52373>
- List-id: <zsh-workers.zsh.org>
I came across a couple of cases where numbers could be specified with a
% suffix for a percentage and the _numbers function was losing this in
the group description in the second zformat pass. The following fixes
this and makes use of it for xz and dumpadm completions. In the case
of xz, there are a few other minor updates to bring it in line with xz
5.4.5.
Oliver
diff --git a/Completion/Base/Utility/_numbers b/Completion/Base/Utility/_numbers
index 97bb8b4c8..069fc75a4 100644
--- a/Completion/Base/Utility/_numbers
+++ b/Completion/Base/Utility/_numbers
@@ -73,7 +73,7 @@ elif [[ -prefix $~pat || $PREFIX = $~partial ]]; then
zformat -f suffix "$suffixfmt" "x:${${argv[i+1]#:}%%:*}" \
"X:${${argv[i+1]#:}#*:}" "d:${#${argv[i+1]}[1]#:}" \
i:i r:$(( $# - i - 1))
- suffixes+="$suffix"
+ suffixes+="${suffix//\%/%%}"
done
[[ -n $suffixes ]] && formats+=( x:$suffixes )
diff --git a/Completion/Solaris/Command/_dumpadm b/Completion/Solaris/Command/_dumpadm
index 44d681ae0..aa1c058bb 100644
--- a/Completion/Solaris/Command/_dumpadm
+++ b/Completion/Solaris/Command/_dumpadm
@@ -16,7 +16,7 @@ _arguments -s \
'-y[run savecore on reboot]' \
'-c[set dump content]:dump content:(($content))' \
'-d[set dump device]: : _alternative "tokens\:token\:(swap none)" "files\:block device\:_files -g \*\(-%b\)"' \
- '-m[set minfree size]:size' \
+ '-m[set minfree size]: :_numbers size k m %' \
'-s[set the savecore directory]:directory:_files -/' \
'-r[alternate root directory]:directory:_files -/' \
'-z[enable saving core files in a compressed format]:compression:(on off)'
diff --git a/Completion/Unix/Command/_xz b/Completion/Unix/Command/_xz
index a4dfea1f5..6e68e0f69 100644
--- a/Completion/Unix/Command/_xz
+++ b/Completion/Unix/Command/_xz
@@ -22,20 +22,20 @@ case "$service" in
'(I)*'{-v,--verbose}'[verbose mode]' \
'(I * --files --files0)--files=-[read list of files to process from file]::file:_files' \
'(I * --files --files0)--files0=-[read null terminated list of files to process from file]::file:_files' \
- '(I -F --format)'{-F,--format}'=[specify file format]:format:(auto xz lzma raw)' \
+ '(I -F --format)'{-F+,--format=}'[specify file format]:format:(auto xz lzma lzip raw)' \
'(I -T --threads)'{-T+,--threads=}'[use specified number of threads]:threads [1]' \
- '(I -M --memlimit --memory)'{-M+,--memlimit=,--memory=}'[set memory usage limit]:memory usage' \
+ '(I -M --memlimit --memory)'{-M+,--memlimit=,--memory=}'[set memory usage limit]: :_numbers -u bytes "memory limit" KiB MiB GiB %\:percentage\ of\ available\ RAM' \
'(I)--no-adjust[give error if settings exceed memory limit]' \
'(I -Q --no-warn)'{-Q,--no-warn}'[make warnings not affect exit status]' \
+ 'comp' \
"(I decomp)"{-z,--compress}'[compress]' \
'(I decomp -e --extreme)'{-e,--extreme}'[try to improve compression ratio by using more CPU time]' \
'(I decomp -S --suffix)'{-S+,--suffix=}'[use specified suffix for compressed files]:suffix [.xz]' \
- '(I decomp -C --check)'{-C,--check}'=[integrity check type]:check type:(none crc32 crc64 sha256)' \
+ '(I decomp -C --check)'{-C+,--check=}'[integrity check type]:check type:(none crc32 crc64 sha256)' \
'(I decomp)--block-size=[start a new .xz block after specified bytes of input]:size' \
'(I decomp)--block-list=[start a new .xz block after specified intervals of uncompressed data]:size' \
'(I decomp)--flush-timeout=[specify maximum time between flushing of output]:time (ms) [0]' \
- '(I decomp)--memlimit-compress=[set memory usage limit for compression]:memory usage' \
+ '(I decomp)--memlimit-compress=[set memory usage limit for compression]: :_numbers -u bytes "memory limit" KiB MiB GiB %\:percentage\ of\ available\ RAM' \
+ 'decomp' \
'(I comp level filters)'{-d,--decompress}'[decompress]' \
'(I comp level filters)'{-t,--test}'[test compressed file integrity]' \
@@ -43,7 +43,8 @@ case "$service" in
"(I comp level filters)--ignore-check[don't verify integrity when decompressing]" \
'(I comp level filters)--single-stream[decompress only the first stream]' \
"(I comp level filters)--no-sparse[don't create sparse files when decompressing]" \
- '(I comp level filters)--memlimit-decompress=[set memory usage limit for decompression]:memory usage' \
+ '(I comp level filters)--memlimit-decompress=[set memory usage limit for decompression]: :_numbers -u bytes "memory limit" KiB MiB GiB %\:percentage\ of\ available\ RAM' \
+ '(I comp level filters)--memlimit-mt-decompress=[set memory usage limit for multi‐threaded decompression]: :_numbers -u bytes "memory limit" KiB MiB GiB %\:percentage\ of\ available\ RAM' \
+ '(I)' \
'(* comp decomp level filters common)--info-memory[display amount of RAM and memory usage limits]' \
'(- *)'{-h,--help}'[display help message]' \
@@ -52,7 +53,7 @@ case "$service" in
+ '(level)' \
'(I filters decomp)-'{-best,-fast,1,2,3,4,5,6,7,8,9} \
+ filters \
- '(I level decomp --extreme)'--{x86,powerpc,ia64,arm,armthumb,sparc}=-'[add a branch/call/jump filter]::option:->bcj-options' \
+ '(I level decomp --extreme)'--{x86,powerpc,ia64,arm,armthumb,arm64,sparc}=-'[add a branch/call/jump filter]::option:->bcj-options' \
'(I level decomp --extreme)'--lzma{1,2}=-'[add lzma filter]::option:->lzma-options' \
'(I level decomp --extreme)--delta=-[add delta filter]::option:->delta-options' && ret=0
;;
@@ -64,10 +65,10 @@ case $state in
[[ -n ${(k)opt_args[(i)decomp*]} ]] && unset decompress
if [[ -z "$decompress" ]]; then
_description files expl 'compressed file'
- _files "$expl[@]" -g '*.(xz|txz|lzma|tlz)(-.)' && return
+ _files "$expl[@]" -g '*.(xz|txz||lz|lzma|tlz)(-.)' && return
else
_description files expl 'file to compress'
- _files "$expl[@]" -g '^*.(xz|txz|lzma|tlz)(-.)' && return
+ _files "$expl[@]" -g '^*.(xz|txz|lz|lzma|tlz)(-.)' && return
fi
;;
lzma-options)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author