diff --git a/src/builtins/commandline.rs b/src/builtins/commandline.rs index df098c8f4..9be604909 100644 --- a/src/builtins/commandline.rs +++ b/src/builtins/commandline.rs @@ -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() diff --git a/tests/checks/commandline.fish b/tests/checks/commandline.fish index 3ce76c1cc..16e80cea8 100644 --- a/tests/checks/commandline.fish +++ b/tests/checks/commandline.fish @@ -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