commandline: Borrow libdata later

builtin_print_help will end up borrowing it as mutable.

Fixes #10342
This commit is contained in:
Fabian Boehm 2024-03-04 16:51:57 +01:00
parent ff6fd699fe
commit 031dbb33b1
2 changed files with 6 additions and 2 deletions

View file

@ -198,8 +198,6 @@ pub fn commandline(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr])
let mut range = 0..0;
let mut override_buffer = None;
let ld = parser.libdata();
const short_options: &wstr = L!(":abijpctfxorhI:CBELSsP");
let long_options: &[woption] = &[
wopt(L!("append"), woption_argument_t::no_argument, 'a'),
@ -292,6 +290,8 @@ pub fn commandline(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr])
let positional_args = w.argv.len() - w.woptind;
let ld = parser.libdata();
if function_mode {
// Check for invalid switch combinations.
if buffer_part.is_some()

View file

@ -17,3 +17,7 @@ or echo Invalid $status
commandline --input 'echo $$' --is-valid
or echo Invalid $status
# CHECK: Invalid 1
commandline --help >/dev/null
echo Invalid $status
# CHECK: 1