diff --git a/fish-rust/src/builtins/argparse.rs b/fish-rust/src/builtins/argparse.rs index d18dac750..3fd179b3e 100644 --- a/fish-rust/src/builtins/argparse.rs +++ b/fish-rust/src/builtins/argparse.rs @@ -12,7 +12,7 @@ use crate::ffi::Repin; use crate::wchar::{wstr, WString, L}; use crate::wchar_ext::WExt; use crate::wcstringutil::split_string; -use crate::wgetopt::{wgetopter_t, wopt, woption, woption_argument_t}; +use crate::wgetopt::{wgetopter_t, wopt, woption, woption_argument_t, NONOPTION_CHAR_CODE}; use crate::wutil::{fish_iswalnum, fish_wcstol, wgettext_fmt}; use libc::c_int; @@ -832,7 +832,7 @@ fn argparse_parse_flags<'args>( STATUS_CMD_OK } } - '\u{1}' => { + NONOPTION_CHAR_CODE => { // A non-option argument. // We use `-` as the first option-string-char to disable GNU getopt's reordering, // otherwise we'd get ignored options first and normal arguments later. diff --git a/fish-rust/src/wgetopt.rs b/fish-rust/src/wgetopt.rs index bc4224c98..8caddfe73 100644 --- a/fish-rust/src/wgetopt.rs +++ b/fish-rust/src/wgetopt.rs @@ -54,6 +54,9 @@ enum Ordering { RETURN_IN_ORDER, } +/// The special character code, enabled via RETURN_IN_ORDER, indicating a non-option argument. +pub const NONOPTION_CHAR_CODE: char = '\x01'; + impl Default for Ordering { fn default() -> Self { Ordering::PERMUTE @@ -323,7 +326,7 @@ impl<'opts, 'args, 'argarray> wgetopter_t<'opts, 'args, 'argarray> { } self.woptarg = Some(self.argv[self.woptind]); self.woptind += 1; - return Some(char::from(1)); + return Some(NONOPTION_CHAR_CODE); } // We have found another option-ARGV-element. Skip the initial punctuation.