zsh-workers
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: Stephane Chazelas <stephane@chazelas.org>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: [PATCH] ulimit option completions using ulimit -a output
Date: Tue, 13 Apr 2021 14:35:55 +0000	[thread overview]
Message-ID: <20210413143555.GL6819@tarpaulin.shahaf.local2> (raw)
In-Reply-To: <20201126201431.a6ym56gcagomyvzk@chazelas.org>

Stephane Chazelas wrote on Thu, Nov 26, 2020 at 20:14:31 +0000:
> 2020-11-26 00:43:33 +0100, Oliver Kiddle:
> [...]
> > >   * 1. Add zsh_LIMIT_PRESENT(RLIMIT_XXX) in configure.ac.
> > >   * 2. Add an entry for RLIMIT_XXX to known_resources[].
> > >   *    Make sure the option letter (resinto_T.opt) is unique.
> > > - * 3. Build zsh and run the test B12rlimit.ztst.
> > > + * 3. Add entry in documentation for the limit and ulimit builtins
> > > + * 4. Build zsh and run the test B12rlimit.ztst.
> > 
> > 5. Update Completion/Zsh/Command/_ulimit
> > 
> > Units were often fairly well documented there but are missing in a
> > couple of cases so you may be able to add a couple.
> [...]
> 
> The problem is that the list of ulimit options is system
> dependent, so I propose the improvement below which uses the
> output of ulimit -a to build the list of completions.

Sorry for the very large delay on getting to review this.  Thanks
Lawrence for fishing it out of the archives.  Review:

> From: Stephane Chazelas <stephane@chazelas.org>
> Date: Thu, 26 Nov 2020 19:22:03 +0000
> Subject: [PATCH] ulimit option completions using ulimit -a output
> 
> The list of options supported by ulimit is system dependent. Rather than
> hardcoding the full list of options supported on any system in the
> completer, we get the list of options from the output of "ulimit -a".

+1

> That means less descriptive descriptions but more relevant completions
> to the user (and not having to update the completer every time a new
> limit is added).

Should we copy the more-descriptive descriptions to the output of
`ulimit -a`?  (I.e., known_resources[] in Src/Modules/rlimits.c)

> +++ b/Completion/Zsh/Command/_ulimit
> @@ -2,18 +2,16 @@
>  
>  [[ $PREFIX = u* ]] && compadd unlimited && return 0
>  
> +local -a opts
> +setopt localoptions extendedglob
> +
> +opts=(
> +  ${${${(fo)"$(ulimit -a)"}:#-N*}%%  *}
> +)
>  _arguments -s \
>    '-H[set hard limits]' \
>    '-S[set soft and hard limits (with -H)]' \
> -  '(-H -S -c -d -f -l -m -n -s -t *)-a[list all current resource limits]' \
> -  '-c[core dump size limit]:max core dump size (512-byte blocks)' \
> -  '-d[maximum size of data segment]:maximum size of data segment (K-bytes)' \
> -  '-f[size of largest file allowed]:size of largest file allowed (512-byte blocks)' \
> -  '-l[maximum size of locked in memory]:maximum size of locked in memory (K-bytes)' \
> -  '-m[maximum size of physical memory]:maximum size of physical memory (K-bytes)' \
> -  '-n[maximum no. of open file descriptors]:maximum no. of open file descriptors' \
> -  '-s[stack size limit]:stack size limit (K-bytes)' \
> -  '-t[maximum cpu time per process]:maximum cpu time per process (seconds)' \
> -  '-u[processes available to the user]:processes' \
> -  '-v[maximum size of virtual memory]:maximum size of virtual memory (K-bytes)' \
> -  '*:size of largest file allowed'
> +  '-N+[specify limit by number]:limit number::limit value' \

[Corrected per 47661]

Why is the second argument optional?  s/::/: :/?

Completing «-N 15 <TAB>» doesn't offer "rt cpu time (microseconds)",
even though the output of `ulimit -a` does show that description.

Completing after «-N <TAB>» could offer "15".

> +  "(-N ${(M@j: :)opts#-?} *)-a[list all current resource limits]" \
> +  ${opts/(#b)(-?): (*)/$match[1][$match[2]]:$match[2]} \

Escape colons in ${match[1]} and ${match[2]}.

It would be nice to retain the current values in in $opts and then
include them in the `message' part of the spec.

> +  '*:file size (blocks)'

Sorry, what's this?  The manual does mention additional positional
arguments, but doesn't describe them, does it?

Sorry again for our very late review.

Review points that aren't regressions aren't blockers.

Daniel


  parent reply	other threads:[~2021-04-13 14:36 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-23 21:49 [PATCHv1] [long] improvements to limit/ulimit API and doc Stephane Chazelas
2020-11-25  0:35 ` Daniel Shahaf
2020-11-25  6:44   ` Stephane Chazelas
2020-11-27 17:16     ` Daniel Shahaf
2020-11-26  6:57   ` [PATCHv2 1/2] [long] improvements to limit/ulimit API and doc ((un)limit in csh emulation) Stephane Chazelas
2020-11-25 23:43 ` [PATCHv1] [long] improvements to limit/ulimit API and doc Oliver Kiddle
2020-11-26 20:14   ` [PATCH] ulimit option completions using ulimit -a output Stephane Chazelas
2020-11-27  7:13     ` Stephane Chazelas
2020-11-27  8:15       ` Felipe Contreras
2020-11-27 12:19       ` Oliver Kiddle
2021-03-27 21:25         ` Lawrence Velázquez
2021-04-03 14:57           ` Lawrence Velázquez
2021-04-10 20:11             ` Lawrence Velázquez
2021-04-13 14:35     ` Daniel Shahaf [this message]
2021-05-09 20:37       ` Lawrence Velázquez
2021-05-11 19:05         ` Stephane Chazelas
2020-11-26 20:58   ` [PATCHv2 2/2] [long] improvements to limit/ulimit API and doc (the rest) Stephane Chazelas
2020-11-27 16:39     ` Daniel Shahaf
2020-11-27 20:13       ` Stephane Chazelas
2020-11-27 20:36         ` Daniel Shahaf
2020-11-28  6:52           ` zsh coding style (was about a limit patch review) Stephane Chazelas
2020-12-01 16:47             ` Daniel Shahaf
2020-11-28  8:16         ` [PATCHv3 2/2] [long] improvements to limit/ulimit API and doc (the rest) Stephane Chazelas
2021-03-27 21:21           ` Lawrence Velázquez
2021-03-31 18:06             ` Stephane Chazelas
2020-11-26 11:19 ` [PATCHv1] [long] improvements to limit/ulimit API and doc Jun T
2020-11-26 13:55   ` Stephane Chazelas
2020-11-26 15:22     ` Jun. T
2020-11-26 17:23       ` Stephane Chazelas
2020-11-27 18:24         ` Jun. T
2020-11-27 18:34           ` Daniel Shahaf
2020-11-27 20:46           ` Stephane Chazelas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210413143555.GL6819@tarpaulin.shahaf.local2 \
    --to=d.s@daniel.shahaf.name \
    --cc=stephane@chazelas.org \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).