Saturate exit codes to 255 for all builtins

After commit 6dd6a57c60, 3 remaining
builtins were affected by uint8_t overflow: `exit`, `return`, and
`functions --query`.

This commit:
- Moves the overflow check from `builtin_set_query` to `builtin_run`.
- Removes a conflicting int -> uint8_t conversion in `builtin_return`.
- Adds tests for the 3 remaining affected builtins.
- Simplifies the wording for the documentation for `set --query`.
- Does not change documentation for `functions --query`, because it does
  not state the exit code in its API.
- Updates the CHANGELOG to reflect the change to all builtins.
This commit is contained in:
Ethel Morgan
2021-02-08 21:25:30 +00:00
committed by Johannes Altmanninger
parent e27d97b02e
commit 5a0aa7824f
8 changed files with 31 additions and 11 deletions

View File

@@ -565,13 +565,6 @@ static int builtin_set_query(const wchar_t *cmd, set_cmd_opts_t &opts, int argc,
free(dest);
}
// The return value is cast to an 8-bit unsigned integer,
// so saturate the error count to 255.
// Otherwise 256 errors is reported as 0 errors.
if (retval > 255) {
retval = 255;
}
return retval;
}