Skip to content

Commit 031dbb3

Browse files
committed
commandline: Borrow libdata later
builtin_print_help will end up borrowing it as mutable. Fixes fish-shell#10342
1 parent ff6fd69 commit 031dbb3

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/builtins/commandline.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,6 @@ pub fn commandline(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr])
198198
let mut range = 0..0;
199199
let mut override_buffer = None;
200200

201-
let ld = parser.libdata();
202-
203201
const short_options: &wstr = L!(":abijpctfxorhI:CBELSsP");
204202
let long_options: &[woption] = &[
205203
wopt(L!("append"), woption_argument_t::no_argument, 'a'),
@@ -292,6 +290,8 @@ pub fn commandline(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr])
292290

293291
let positional_args = w.argv.len() - w.woptind;
294292

293+
let ld = parser.libdata();
294+
295295
if function_mode {
296296
// Check for invalid switch combinations.
297297
if buffer_part.is_some()

tests/checks/commandline.fish

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@ or echo Invalid $status
1717
commandline --input 'echo $$' --is-valid
1818
or echo Invalid $status
1919
# CHECK: Invalid 1
20+
21+
commandline --help >/dev/null
22+
echo Invalid $status
23+
# CHECK: 1

0 commit comments

Comments
 (0)