Saturate return value in builtin_set_query

builtin_set_query returns the number of missing variables. Because the
return value passed to the shell is an 8-bit unsigned integer, if the
number of missing variables is a multiple of 256, it would overflow to 0.

This commit saturates the return value at 255 if there are more than 255
missing variables.
This commit is contained in:
Ethel Morgan
2021-02-08 15:19:21 +00:00
committed by Fabian Homborg
parent 42c75111c8
commit 6dd6a57c60
4 changed files with 17 additions and 2 deletions

View File

@@ -49,7 +49,7 @@ The following options are available:
- ``-e`` or ``--erase`` causes the specified shell variables to be erased
- ``-q`` or ``--query`` test if the specified variable names are defined. Does not output anything, but the builtins exit status is the number of variables specified that were not defined.
- ``-q`` or ``--query`` test if the specified variable names are defined. Does not output anything, but the builtins exit status is the number of variables specified that were not defined, saturating at 255 if more than 255 variables are not defined.
- ``-n`` or ``--names`` List only the names of all defined variables, not their value. The names are guaranteed to be sorted.