diff --git a/src/uu/base32/src/base32.rs b/src/uu/base32/src/base32.rs index 8e02f03e0..a93b4e18b 100644 --- a/src/uu/base32/src/base32.rs +++ b/src/uu/base32/src/base32.rs @@ -29,13 +29,13 @@ static VERSION: &str = env!("CARGO_PKG_VERSION"); static BASE_CMD_PARSE_ERROR: i32 = 1; fn usage() -> String { - format!("{0} [OPTION]... [FILE]", executable!()) + format!("{0} [OPTION]... [FILE]", execution_phrase!()) } pub fn uumain(args: impl uucore::Args) -> i32 { let format = Format::Base32; let usage = usage(); - let name = executable!(); + let name = util_name!(); let config_result: Result = base_common::parse_base_cmd_args(args, name, VERSION, ABOUT, &usage); @@ -59,5 +59,5 @@ pub fn uumain(args: impl uucore::Args) -> i32 { } pub fn uu_app() -> App<'static, 'static> { - base_common::base_app(executable!(), VERSION, ABOUT) + base_common::base_app(util_name!(), VERSION, ABOUT) } diff --git a/src/uu/base64/src/base64.rs b/src/uu/base64/src/base64.rs index 48aee537d..b53ec32e9 100644 --- a/src/uu/base64/src/base64.rs +++ b/src/uu/base64/src/base64.rs @@ -30,13 +30,13 @@ static VERSION: &str = env!("CARGO_PKG_VERSION"); static BASE_CMD_PARSE_ERROR: i32 = 1; fn usage() -> String { - format!("{0} [OPTION]... [FILE]", executable!()) + format!("{0} [OPTION]... [FILE]", execution_phrase!()) } pub fn uumain(args: impl uucore::Args) -> i32 { let format = Format::Base64; let usage = usage(); - let name = executable!(); + let name = util_name!(); let config_result: Result = base_common::parse_base_cmd_args(args, name, VERSION, ABOUT, &usage); let config = config_result.unwrap_or_else(|s| crash!(BASE_CMD_PARSE_ERROR, "{}", s)); diff --git a/src/uu/basename/src/basename.rs b/src/uu/basename/src/basename.rs index f3c9f5391..8de55af80 100644 --- a/src/uu/basename/src/basename.rs +++ b/src/uu/basename/src/basename.rs @@ -21,7 +21,7 @@ fn usage() -> String { format!( "{0} NAME [SUFFIX] {0} OPTION... NAME...", - executable!() + execution_phrase!() ) } @@ -47,7 +47,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { crash!( 1, "{1}\nTry `{0} --help` for more information.", - executable!(), + execution_phrase!(), "missing operand" ); } @@ -61,7 +61,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { crash!( 1, "extra operand '{1}'\nTry `{0} --help` for more information.", - executable!(), + execution_phrase!(), matches.values_of(options::NAME).unwrap().nth(2).unwrap() ); } diff --git a/src/uu/chgrp/src/chgrp.rs b/src/uu/chgrp/src/chgrp.rs index 11a45c90a..5dbcc277e 100644 --- a/src/uu/chgrp/src/chgrp.rs +++ b/src/uu/chgrp/src/chgrp.rs @@ -62,7 +62,7 @@ const FTS_LOGICAL: u8 = 1 << 2; fn usage() -> String { format!( "{0} [OPTION]... GROUP FILE...\n {0} [OPTION]... --reference=RFILE FILE...", - executable!() + execution_phrase!() ) } diff --git a/src/uu/chmod/src/chmod.rs b/src/uu/chmod/src/chmod.rs index e1d8b32e4..88ad22969 100644 --- a/src/uu/chmod/src/chmod.rs +++ b/src/uu/chmod/src/chmod.rs @@ -41,7 +41,7 @@ fn usage() -> String { "{0} [OPTION]... MODE[,MODE]... FILE... or: {0} [OPTION]... OCTAL-MODE FILE... or: {0} [OPTION]... --reference=RFILE FILE...", - executable!() + execution_phrase!() ) } diff --git a/src/uu/chown/src/chown.rs b/src/uu/chown/src/chown.rs index a5d7c5ac7..a7824f248 100644 --- a/src/uu/chown/src/chown.rs +++ b/src/uu/chown/src/chown.rs @@ -64,7 +64,7 @@ const FTS_LOGICAL: u8 = 1 << 2; fn usage() -> String { format!( "{0} [OPTION]... [OWNER][:[GROUP]] FILE...\n{0} [OPTION]... --reference=RFILE FILE...", - executable!() + execution_phrase!() ) } diff --git a/src/uu/chroot/src/chroot.rs b/src/uu/chroot/src/chroot.rs index 01a7c6b84..b622b51a1 100644 --- a/src/uu/chroot/src/chroot.rs +++ b/src/uu/chroot/src/chroot.rs @@ -16,9 +16,8 @@ use std::io::Error; use std::path::Path; use std::process::Command; use uucore::libc::{self, chroot, setgid, setgroups, setuid}; -use uucore::{entries, InvalidEncodingHandling}; +use uucore::{entries, execution_phrase, InvalidEncodingHandling}; -static NAME: &str = "chroot"; static ABOUT: &str = "Run COMMAND with root directory set to NEWROOT."; static SYNTAX: &str = "[OPTION]... NEWROOT [COMMAND [ARG]...]"; @@ -47,7 +46,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { None => crash!( 1, "Missing operand: NEWROOT\nTry `{} --help` for more information.", - NAME + execution_phrase!() ), }; diff --git a/src/uu/comm/src/comm.rs b/src/uu/comm/src/comm.rs index 36238cd5f..02c5598be 100644 --- a/src/uu/comm/src/comm.rs +++ b/src/uu/comm/src/comm.rs @@ -32,7 +32,7 @@ mod options { } fn usage() -> String { - format!("{} [OPTION]... FILE1 FILE2", executable!()) + format!("{} [OPTION]... FILE1 FILE2", execution_phrase!()) } fn mkdelim(col: usize, opts: &ArgMatches) -> String { diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index 406f6757d..086b734e8 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -99,7 +99,7 @@ quick_error! { NotImplemented(opt: String) { display("Option '{}' not yet implemented.", opt) } /// Invalid arguments to backup - Backup(description: String) { display("{}\nTry `{} --help` for more information.", description, executable!()) } + Backup(description: String) { display("{}\nTry `{} --help` for more information.", description, execution_phrase!()) } } } @@ -223,7 +223,7 @@ fn usage() -> String { "{0} [OPTION]... [-T] SOURCE DEST {0} [OPTION]... SOURCE... DIRECTORY {0} [OPTION]... -t DIRECTORY SOURCE...", - executable!() + execution_phrase!() ) } @@ -1060,7 +1060,7 @@ impl OverwriteMode { match *self { OverwriteMode::NoClobber => Err(Error::NotAllFilesCopied), OverwriteMode::Interactive(_) => { - if prompt_yes!("{}: overwrite {}? ", executable!(), path.display()) { + if prompt_yes!("{}: overwrite {}? ", util_name!(), path.display()) { Ok(()) } else { Err(Error::Skipped(format!( diff --git a/src/uu/csplit/src/csplit.rs b/src/uu/csplit/src/csplit.rs index 409b17b98..c89d06cf3 100644 --- a/src/uu/csplit/src/csplit.rs +++ b/src/uu/csplit/src/csplit.rs @@ -35,7 +35,7 @@ mod options { } fn usage() -> String { - format!("{0} [OPTION]... FILE PATTERN...", executable!()) + format!("{0} [OPTION]... FILE PATTERN...", execution_phrase!()) } /// Command line options for csplit. diff --git a/src/uu/df/src/df.rs b/src/uu/df/src/df.rs index 4ffa8b532..52fae4702 100644 --- a/src/uu/df/src/df.rs +++ b/src/uu/df/src/df.rs @@ -80,7 +80,7 @@ struct Filesystem { } fn usage() -> String { - format!("{0} [OPTION]... [FILE]...", executable!()) + format!("{0} [OPTION]... [FILE]...", execution_phrase!()) } impl FsSelector { @@ -295,7 +295,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { #[cfg(windows)] { if matches.is_present(OPT_INODES) { - println!("{}: doesn't support -i option", executable!()); + println!("{}: doesn't support -i option", util_name!()); return Ok(()); } } diff --git a/src/uu/dircolors/src/dircolors.rs b/src/uu/dircolors/src/dircolors.rs index 90b48c301..c70fd97ee 100644 --- a/src/uu/dircolors/src/dircolors.rs +++ b/src/uu/dircolors/src/dircolors.rs @@ -63,7 +63,7 @@ pub fn guess_syntax() -> OutputFmt { } fn usage() -> String { - format!("{0} {1}", executable!(), SYNTAX) + format!("{0} {1}", execution_phrase!(), SYNTAX) } pub fn uumain(args: impl uucore::Args) -> i32 { diff --git a/src/uu/dirname/src/dirname.rs b/src/uu/dirname/src/dirname.rs index 3162bef48..4600d67ac 100644 --- a/src/uu/dirname/src/dirname.rs +++ b/src/uu/dirname/src/dirname.rs @@ -21,7 +21,7 @@ mod options { } fn usage() -> String { - format!("{0} [OPTION] NAME...", executable!()) + format!("{0} [OPTION] NAME...", execution_phrase!()) } fn get_long_usage() -> String { diff --git a/src/uu/du/src/du.rs b/src/uu/du/src/du.rs index 56f412ffb..2c430d693 100644 --- a/src/uu/du/src/du.rs +++ b/src/uu/du/src/du.rs @@ -396,7 +396,7 @@ fn usage() -> String { format!( "{0} [OPTION]... [FILE]... {0} [OPTION]... --files0-from=F", - executable!() + execution_phrase!() ) } @@ -424,7 +424,7 @@ Valid arguments are: - 'iso' Try `{} --help` for more information.", s, - executable!() + execution_phrase!() ), DuError::InvalidTimeArg(s) => write!( f, diff --git a/src/uu/expand/src/expand.rs b/src/uu/expand/src/expand.rs index 29de6ae44..0cd4b2719 100644 --- a/src/uu/expand/src/expand.rs +++ b/src/uu/expand/src/expand.rs @@ -33,7 +33,7 @@ static LONG_HELP: &str = ""; static DEFAULT_TABSTOP: usize = 8; fn usage() -> String { - format!("{0} [OPTION]... [FILE]...", executable!()) + format!("{0} [OPTION]... [FILE]...", execution_phrase!()) } /// The mode to use when replacing tabs beyond the last one specified in diff --git a/src/uu/expr/src/expr.rs b/src/uu/expr/src/expr.rs index b37e1ced6..0a9d76f67 100644 --- a/src/uu/expr/src/expr.rs +++ b/src/uu/expr/src/expr.rs @@ -140,5 +140,5 @@ Environment variables: } fn print_version() { - println!("{} {}", executable!(), crate_version!()); + println!("{} {}", util_name!(), crate_version!()); } diff --git a/src/uu/fmt/src/fmt.rs b/src/uu/fmt/src/fmt.rs index 80f74cf84..d42151503 100644 --- a/src/uu/fmt/src/fmt.rs +++ b/src/uu/fmt/src/fmt.rs @@ -51,7 +51,7 @@ static OPT_TAB_WIDTH: &str = "tab-width"; static ARG_FILES: &str = "files"; fn usage() -> String { - format!("{} [OPTION]... [FILE]...", executable!()) + format!("{} [OPTION]... [FILE]...", execution_phrase!()) } pub type FileOrStdReader = BufReader>; diff --git a/src/uu/groups/src/groups.rs b/src/uu/groups/src/groups.rs index fe1065cc1..83be0932b 100644 --- a/src/uu/groups/src/groups.rs +++ b/src/uu/groups/src/groups.rs @@ -29,7 +29,7 @@ static ABOUT: &str = "Print group memberships for each USERNAME or, \ (which may differ if the groups data‐base has changed)."; fn usage() -> String { - format!("{0} [OPTION]... [USERNAME]...", executable!()) + format!("{0} [OPTION]... [USERNAME]...", execution_phrase!()) } pub fn uumain(args: impl uucore::Args) -> i32 { diff --git a/src/uu/hostname/src/hostname.rs b/src/uu/hostname/src/hostname.rs index 2b7deb565..2dc68abfb 100644 --- a/src/uu/hostname/src/hostname.rs +++ b/src/uu/hostname/src/hostname.rs @@ -54,7 +54,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } fn usage() -> String { - format!("{0} [OPTION]... [HOSTNAME]", executable!()) + format!("{0} [OPTION]... [HOSTNAME]", execution_phrase!()) } fn execute(args: impl uucore::Args) -> UResult<()> { diff --git a/src/uu/id/src/id.rs b/src/uu/id/src/id.rs index 16c521ea3..74523213e 100644 --- a/src/uu/id/src/id.rs +++ b/src/uu/id/src/id.rs @@ -77,7 +77,7 @@ mod options { } fn usage() -> String { - format!("{0} [OPTION]... [USER]...", executable!()) + format!("{0} [OPTION]... [USER]...", execution_phrase!()) } fn get_description() -> String { diff --git a/src/uu/install/src/install.rs b/src/uu/install/src/install.rs index 5ee103e0f..a1c6d4225 100644 --- a/src/uu/install/src/install.rs +++ b/src/uu/install/src/install.rs @@ -89,7 +89,7 @@ impl Display for InstallError { IE::DirNeedsArg() => write!( f, "{} with -d requires at least one argument.", - executable!() + util_name!() ), IE::CreateDirFailed(dir, e) => { Display::fmt(&uio_error!(e, "failed to create {}", dir.display()), f) @@ -173,7 +173,7 @@ static OPT_CONTEXT: &str = "context"; static ARG_FILES: &str = "files"; fn usage() -> String { - format!("{0} [OPTION]... [FILE]...", executable!()) + format!("{0} [OPTION]... [FILE]...", execution_phrase!()) } /// Main install utility function, called from main.rs. diff --git a/src/uu/kill/src/kill.rs b/src/uu/kill/src/kill.rs index e9ec70964..08dff87d4 100644 --- a/src/uu/kill/src/kill.rs +++ b/src/uu/kill/src/kill.rs @@ -41,7 +41,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { .accept_any(); let (args, obs_signal) = handle_obsolete(args); - let usage = format!("{} [OPTIONS]... PID...", executable!()); + let usage = format!("{} [OPTIONS]... PID...", execution_phrase!()); let matches = uu_app().usage(&usage[..]).get_matches_from(args); let mode = if matches.is_present(options::TABLE) || matches.is_present(options::TABLE_OLD) { diff --git a/src/uu/link/src/link.rs b/src/uu/link/src/link.rs index d06025815..03dd46aee 100644 --- a/src/uu/link/src/link.rs +++ b/src/uu/link/src/link.rs @@ -20,7 +20,7 @@ pub mod options { } fn usage() -> String { - format!("{0} FILE1 FILE2", executable!()) + format!("{0} FILE1 FILE2", execution_phrase!()) } pub fn normalize_error_message(e: Error) -> String { diff --git a/src/uu/ln/src/ln.rs b/src/uu/ln/src/ln.rs index 572c68379..62748ae78 100644 --- a/src/uu/ln/src/ln.rs +++ b/src/uu/ln/src/ln.rs @@ -70,7 +70,7 @@ impl Display for LnError { f, "extra operand '{}'\nTry `{} --help` for more information.", s, - executable!() + execution_phrase!() ), Self::InvalidBackupMode(s) => write!(f, "{}", s), } @@ -98,7 +98,7 @@ fn usage() -> String { {0} [OPTION]... TARGET (2nd form) {0} [OPTION]... TARGET... DIRECTORY (3rd form) {0} [OPTION]... -t DIRECTORY TARGET... (4th form)", - executable!() + execution_phrase!() ) } @@ -431,7 +431,7 @@ fn link(src: &Path, dst: &Path, settings: &Settings) -> Result<()> { match settings.overwrite { OverwriteMode::NoClobber => {} OverwriteMode::Interactive => { - print!("{}: overwrite '{}'? ", executable!(), dst.display()); + print!("{}: overwrite '{}'? ", util_name!(), dst.display()); if !read_yes() { return Ok(()); } diff --git a/src/uu/logname/src/logname.rs b/src/uu/logname/src/logname.rs index 095f3fc84..e9952ddef 100644 --- a/src/uu/logname/src/logname.rs +++ b/src/uu/logname/src/logname.rs @@ -36,7 +36,7 @@ fn get_userlogin() -> Option { static SUMMARY: &str = "Print user's login name"; fn usage() -> String { - String::from(executable!()) + execution_phrase!().to_string() } pub fn uumain(args: impl uucore::Args) -> i32 { diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index f02a53738..6ba3ec4f1 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -47,7 +47,7 @@ use uucore::libc::{S_IXGRP, S_IXOTH, S_IXUSR}; use uucore::{fs::display_permissions, version_cmp::version_cmp}; fn usage() -> String { - format!("{0} [OPTION]... [FILE]...", executable!()) + format!("{0} [OPTION]... [FILE]...", execution_phrase!()) } pub mod options { diff --git a/src/uu/mkdir/src/mkdir.rs b/src/uu/mkdir/src/mkdir.rs index e9aa4bc22..046628f3a 100644 --- a/src/uu/mkdir/src/mkdir.rs +++ b/src/uu/mkdir/src/mkdir.rs @@ -23,7 +23,7 @@ mod options { } fn usage() -> String { - format!("{0} [OPTION]... [USER]", executable!()) + format!("{0} [OPTION]... [USER]", execution_phrase!()) } #[uucore_procs::gen_uumain] @@ -103,7 +103,7 @@ fn mkdir(path: &Path, recursive: bool, mode: u16, verbose: bool) -> UResult<()> create_dir(path).map_err_context(|| format!("cannot create directory '{}'", path.display()))?; if verbose { - println!("{}: created directory '{}'", executable!(), path.display()); + println!("{}: created directory '{}'", util_name!(), path.display()); } chmod(path, mode) diff --git a/src/uu/mknod/src/mknod.rs b/src/uu/mknod/src/mknod.rs index bd26949cd..19c61bcfe 100644 --- a/src/uu/mknod/src/mknod.rs +++ b/src/uu/mknod/src/mknod.rs @@ -18,7 +18,6 @@ use libc::{S_IFBLK, S_IFCHR, S_IFIFO, S_IRGRP, S_IROTH, S_IRUSR, S_IWGRP, S_IWOT use uucore::InvalidEncodingHandling; -static NAME: &str = "mknod"; static ABOUT: &str = "Create the special file NAME of the given TYPE."; static USAGE: &str = "mknod [OPTION]... NAME TYPE [MAJOR MINOR]"; static LONG_HELP: &str = "Mandatory arguments to long options are mandatory for short options too. @@ -72,7 +71,8 @@ fn _mknod(file_name: &str, mode: mode_t, dev: dev_t) -> i32 { } if errno == -1 { - let c_str = CString::new(NAME).expect("Failed to convert to CString"); + let c_str = + CString::new(execution_phrase!().as_bytes()).expect("Failed to convert to CString"); // shows the error from the mknod syscall libc::perror(c_str.as_ptr()); } @@ -113,7 +113,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { if ch == 'p' { if matches.is_present("major") || matches.is_present("minor") { eprintln!("Fifos do not have major and minor device numbers."); - eprintln!("Try `{} --help` for more information.", NAME); + eprintln!("Try `{} --help` for more information.", execution_phrase!()); 1 } else { _mknod(file_name, S_IFIFO | mode, 0) @@ -122,7 +122,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { match (matches.value_of("major"), matches.value_of("minor")) { (None, None) | (_, None) | (None, _) => { eprintln!("Special files require major and minor device numbers."); - eprintln!("Try `{} --help` for more information.", NAME); + eprintln!("Try `{} --help` for more information.", execution_phrase!()); 1 } (Some(major), Some(minor)) => { diff --git a/src/uu/mktemp/src/mktemp.rs b/src/uu/mktemp/src/mktemp.rs index 52d60d140..2d42d38ba 100644 --- a/src/uu/mktemp/src/mktemp.rs +++ b/src/uu/mktemp/src/mktemp.rs @@ -37,7 +37,7 @@ static OPT_T: &str = "t"; static ARG_TEMPLATE: &str = "template"; fn usage() -> String { - format!("{0} [OPTION]... [TEMPLATE]", executable!()) + format!("{0} [OPTION]... [TEMPLATE]", execution_phrase!()) } #[derive(Debug)] diff --git a/src/uu/mv/src/mv.rs b/src/uu/mv/src/mv.rs index 1c25e653c..ecd57ee5a 100644 --- a/src/uu/mv/src/mv.rs +++ b/src/uu/mv/src/mv.rs @@ -63,7 +63,7 @@ fn usage() -> String { "{0} [OPTION]... [-T] SOURCE DEST {0} [OPTION]... SOURCE... DIRECTORY {0} [OPTION]... -t DIRECTORY SOURCE...", - executable!() + execution_phrase!() ) } @@ -296,7 +296,7 @@ fn exec(files: &[PathBuf], b: Behavior) -> i32 { "mv: extra operand '{}'\n\ Try `{} --help` for more information.", files[2].display(), - executable!() + execution_phrase!() ); return 1; } @@ -353,7 +353,7 @@ fn rename(from: &Path, to: &Path, b: &Behavior) -> io::Result<()> { match b.overwrite { OverwriteMode::NoClobber => return Ok(()), OverwriteMode::Interactive => { - println!("{}: overwrite '{}'? ", executable!(), to.display()); + println!("{}: overwrite '{}'? ", util_name!(), to.display()); if !read_yes() { return Ok(()); } diff --git a/src/uu/nice/src/nice.rs b/src/uu/nice/src/nice.rs index c071a875f..835034b74 100644 --- a/src/uu/nice/src/nice.rs +++ b/src/uu/nice/src/nice.rs @@ -31,7 +31,7 @@ Run COMMAND with an adjusted niceness, which affects process scheduling. With no COMMAND, print the current niceness. Niceness values range from at least -20 (most favorable to the process) to 19 (least favorable to the process).", - executable!() + execution_phrase!() ) } @@ -54,7 +54,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { if !matches.is_present(options::COMMAND) { show_error!( "A command must be given with an adjustment.\nTry `{} --help` for more information.", - executable!() + execution_phrase!() ); return 125; } diff --git a/src/uu/nohup/src/nohup.rs b/src/uu/nohup/src/nohup.rs index a6f08e806..17b06301f 100644 --- a/src/uu/nohup/src/nohup.rs +++ b/src/uu/nohup/src/nohup.rs @@ -157,7 +157,7 @@ fn find_stdout() -> File { } fn usage() -> String { - format!("{0} COMMAND [ARG]...\n {0} FLAG", executable!()) + format!("{0} COMMAND [ARG]...\n {0} FLAG", execution_phrase!()) } #[cfg(target_vendor = "apple")] diff --git a/src/uu/nproc/src/nproc.rs b/src/uu/nproc/src/nproc.rs index 427a3cd2f..c10d79d40 100644 --- a/src/uu/nproc/src/nproc.rs +++ b/src/uu/nproc/src/nproc.rs @@ -28,7 +28,7 @@ static OPT_IGNORE: &str = "ignore"; static ABOUT: &str = "Print the number of cores available to the current process."; fn usage() -> String { - format!("{0} [OPTIONS]...", executable!()) + format!("{0} [OPTIONS]...", execution_phrase!()) } pub fn uumain(args: impl uucore::Args) -> i32 { diff --git a/src/uu/numfmt/src/numfmt.rs b/src/uu/numfmt/src/numfmt.rs index 6012bbf82..849abeb71 100644 --- a/src/uu/numfmt/src/numfmt.rs +++ b/src/uu/numfmt/src/numfmt.rs @@ -51,7 +51,7 @@ Multiple fields/ranges can be separated with commas "; fn usage() -> String { - format!("{0} [OPTION]... [NUMBER]...", executable!()) + format!("{0} [OPTION]... [NUMBER]...", execution_phrase!()) } fn handle_args<'a>(args: impl Iterator, options: NumfmtOptions) -> Result<()> { diff --git a/src/uu/od/src/multifilereader.rs b/src/uu/od/src/multifilereader.rs index 1255da66d..303093b01 100644 --- a/src/uu/od/src/multifilereader.rs +++ b/src/uu/od/src/multifilereader.rs @@ -57,12 +57,7 @@ impl<'b> MultifileReader<'b> { // print an error at the time that the file is needed, // then move on the the next file. // This matches the behavior of the original `od` - eprintln!( - "{}: '{}': {}", - executable!().split("::").next().unwrap(), // remove module - fname, - e - ); + eprintln!("{}: '{}': {}", util_name!(), fname, e); self.any_err = true } } @@ -95,11 +90,7 @@ impl<'b> io::Read for MultifileReader<'b> { Ok(0) => break, Ok(n) => n, Err(e) => { - eprintln!( - "{}: I/O: {}", - executable!().split("::").next().unwrap(), // remove module - e - ); + eprintln!("{}: I/O: {}", util_name!(), e); self.any_err = true; break; } diff --git a/src/uu/pathchk/src/pathchk.rs b/src/uu/pathchk/src/pathchk.rs index 4d257a771..65c917ac0 100644 --- a/src/uu/pathchk/src/pathchk.rs +++ b/src/uu/pathchk/src/pathchk.rs @@ -25,7 +25,6 @@ enum Mode { Both, // a combination of `Basic` and `Extra` } -static NAME: &str = "pathchk"; static ABOUT: &str = "Check whether file names are valid or portable"; mod options { @@ -40,7 +39,7 @@ const POSIX_PATH_MAX: usize = 256; const POSIX_NAME_MAX: usize = 14; fn usage() -> String { - format!("{0} [OPTION]... NAME...", executable!()) + format!("{0} [OPTION]... NAME...", execution_phrase!()) } pub fn uumain(args: impl uucore::Args) -> i32 { @@ -71,7 +70,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { let mut res = if paths.is_none() { show_error!( "missing operand\nTry `{} --help` for more information", - NAME + execution_phrase!() ); false } else { diff --git a/src/uu/pinky/src/pinky.rs b/src/uu/pinky/src/pinky.rs index 4aad2c07d..9268ffd2b 100644 --- a/src/uu/pinky/src/pinky.rs +++ b/src/uu/pinky/src/pinky.rs @@ -41,7 +41,7 @@ mod options { } fn usage() -> String { - format!("{0} [OPTION]... [USER]...", executable!()) + format!("{0} [OPTION]... [USER]...", execution_phrase!()) } fn get_long_usage() -> String { diff --git a/src/uu/printenv/src/printenv.rs b/src/uu/printenv/src/printenv.rs index 0e86f1012..da46f7667 100644 --- a/src/uu/printenv/src/printenv.rs +++ b/src/uu/printenv/src/printenv.rs @@ -20,7 +20,7 @@ static OPT_NULL: &str = "null"; static ARG_VARIABLES: &str = "variables"; fn usage() -> String { - format!("{0} [VARIABLE]... [OPTION]...", executable!()) + format!("{0} [VARIABLE]... [OPTION]...", execution_phrase!()) } pub fn uumain(args: impl uucore::Args) -> i32 { diff --git a/src/uu/printf/src/printf.rs b/src/uu/printf/src/printf.rs index 211522fbf..26a1b29b2 100644 --- a/src/uu/printf/src/printf.rs +++ b/src/uu/printf/src/printf.rs @@ -281,11 +281,11 @@ pub fn uumain(args: impl uucore::Args) -> i32 { .collect_str(InvalidEncodingHandling::Ignore) .accept_any(); - let location = &args[0]; if args.len() <= 1 { println!( - "{0}: missing operand\nTry `{0} --help` for more information.", - location + "{0}: missing operand\nTry `{1} --help` for more information.", + util_name!(), + execution_phrase!() ); return 1; } @@ -294,7 +294,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { if formatstr == "--help" { print!("{} {}", LONGHELP_LEAD, LONGHELP_BODY); } else if formatstr == "--version" { - println!("{} {}", executable!(), crate_version!()); + println!("{} {}", util_name!(), crate_version!()); } else { let printf_args = &args[2..]; memo::Memo::run_all(formatstr, printf_args); diff --git a/src/uu/pwd/src/pwd.rs b/src/uu/pwd/src/pwd.rs index bfdfafd13..388a10463 100644 --- a/src/uu/pwd/src/pwd.rs +++ b/src/uu/pwd/src/pwd.rs @@ -35,7 +35,7 @@ pub fn absolute_path(path: &Path) -> io::Result { } fn usage() -> String { - format!("{0} [OPTION]... FILE...", executable!()) + format!("{0} [OPTION]... FILE...", execution_phrase!()) } #[uucore_procs::gen_uumain] diff --git a/src/uu/readlink/src/readlink.rs b/src/uu/readlink/src/readlink.rs index b86dff162..cf788c1fe 100644 --- a/src/uu/readlink/src/readlink.rs +++ b/src/uu/readlink/src/readlink.rs @@ -16,7 +16,6 @@ use std::io::{stdout, Write}; use std::path::{Path, PathBuf}; use uucore::fs::{canonicalize, CanonicalizeMode}; -const NAME: &str = "readlink"; const ABOUT: &str = "Print value of a symbolic link or canonical file name."; const OPT_CANONICALIZE: &str = "canonicalize"; const OPT_CANONICALIZE_MISSING: &str = "canonicalize-missing"; @@ -30,7 +29,7 @@ const OPT_ZERO: &str = "zero"; const ARG_FILES: &str = "files"; fn usage() -> String { - format!("{0} [OPTION]... [FILE]...", executable!()) + format!("{0} [OPTION]... [FILE]...", execution_phrase!()) } pub fn uumain(args: impl uucore::Args) -> i32 { @@ -60,12 +59,15 @@ pub fn uumain(args: impl uucore::Args) -> i32 { crash!( 1, "missing operand\nTry `{} --help` for more information", - NAME + execution_phrase!() ); } if no_newline && files.len() > 1 && !silent { - eprintln!("{}: ignoring --no-newline with multiple arguments", NAME); + eprintln!( + "{}: ignoring --no-newline with multiple arguments", + util_name!() + ); no_newline = false; } @@ -76,7 +78,12 @@ pub fn uumain(args: impl uucore::Args) -> i32 { Ok(path) => show(&path, no_newline, use_zero), Err(err) => { if verbose { - eprintln!("{}: {}: errno {}", NAME, f, err.raw_os_error().unwrap()); + eprintln!( + "{}: {}: errno {}", + util_name!(), + f, + err.raw_os_error().unwrap() + ); } return 1; } @@ -86,7 +93,12 @@ pub fn uumain(args: impl uucore::Args) -> i32 { Ok(path) => show(&path, no_newline, use_zero), Err(err) => { if verbose { - eprintln!("{}: {}: errno {:?}", NAME, f, err.raw_os_error().unwrap()); + eprintln!( + "{}: {}: errno {:?}", + util_name!(), + f, + err.raw_os_error().unwrap() + ); } return 1; } diff --git a/src/uu/realpath/src/realpath.rs b/src/uu/realpath/src/realpath.rs index 494fe41dc..7ce8fc179 100644 --- a/src/uu/realpath/src/realpath.rs +++ b/src/uu/realpath/src/realpath.rs @@ -23,7 +23,7 @@ static OPT_ZERO: &str = "zero"; static ARG_FILES: &str = "files"; fn usage() -> String { - format!("{0} [OPTION]... FILE...", executable!()) + format!("{0} [OPTION]... FILE...", execution_phrase!()) } pub fn uumain(args: impl uucore::Args) -> i32 { diff --git a/src/uu/relpath/src/relpath.rs b/src/uu/relpath/src/relpath.rs index b7fa8991c..941a6a3f2 100644 --- a/src/uu/relpath/src/relpath.rs +++ b/src/uu/relpath/src/relpath.rs @@ -26,7 +26,7 @@ mod options { } fn usage() -> String { - format!("{} [-d DIR] TO [FROM]", executable!()) + format!("{} [-d DIR] TO [FROM]", execution_phrase!()) } pub fn uumain(args: impl uucore::Args) -> i32 { diff --git a/src/uu/rm/src/rm.rs b/src/uu/rm/src/rm.rs index 4b435807b..03977bc3e 100644 --- a/src/uu/rm/src/rm.rs +++ b/src/uu/rm/src/rm.rs @@ -53,7 +53,7 @@ static OPT_VERBOSE: &str = "verbose"; static ARG_FILES: &str = "files"; fn usage() -> String { - format!("{0} [OPTION]... FILE...", executable!()) + format!("{0} [OPTION]... FILE...", execution_phrase!()) } fn get_long_usage() -> String { @@ -93,7 +93,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { // Still check by hand and not use clap // Because "rm -f" is a thing show_error!("missing an argument"); - show_error!("for help, try '{0} --help'", executable!()); + show_error!("for help, try '{0} --help'", execution_phrase!()); return 1; } else { let options = Options { diff --git a/src/uu/rmdir/src/rmdir.rs b/src/uu/rmdir/src/rmdir.rs index 880300a7a..135350a8e 100644 --- a/src/uu/rmdir/src/rmdir.rs +++ b/src/uu/rmdir/src/rmdir.rs @@ -27,7 +27,7 @@ static ENOTDIR: i32 = 20; static ENOTDIR: i32 = 267; fn usage() -> String { - format!("{0} [OPTION]... DIRECTORY...", executable!()) + format!("{0} [OPTION]... DIRECTORY...", execution_phrase!()) } pub fn uumain(args: impl uucore::Args) -> i32 { diff --git a/src/uu/seq/src/seq.rs b/src/uu/seq/src/seq.rs index 2042cf23f..f3e57881e 100644 --- a/src/uu/seq/src/seq.rs +++ b/src/uu/seq/src/seq.rs @@ -27,7 +27,7 @@ fn usage() -> String { "{0} [OPTION]... LAST {0} [OPTION]... FIRST LAST {0} [OPTION]... FIRST INCREMENT LAST", - executable!() + execution_phrase!() ) } #[derive(Clone)] @@ -72,13 +72,13 @@ impl FromStr for Number { Ok(value) if value.is_nan() => Err(format!( "invalid 'not-a-number' argument: '{}'\nTry `{} --help` for more information.", s, - executable!(), + execution_phrase!(), )), Ok(value) => Ok(Number::F64(value)), Err(_) => Err(format!( "invalid floating point argument: '{}'\nTry `{} --help` for more information.", s, - executable!(), + execution_phrase!(), )), }, } @@ -123,7 +123,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { show_error!( "invalid Zero increment value: '{}'\nTry `{} --help` for more information.", numbers[1], - executable!() + execution_phrase!() ); return 1; } diff --git a/src/uu/shred/src/shred.rs b/src/uu/shred/src/shred.rs index 936577f01..521cb8dc6 100644 --- a/src/uu/shred/src/shred.rs +++ b/src/uu/shred/src/shred.rs @@ -214,7 +214,7 @@ for even very expensive hardware probing to recover the data. "; fn usage() -> String { - format!("{} [OPTION]... FILE...", executable!()) + format!("{} [OPTION]... FILE...", execution_phrase!()) } static AFTER_HELP: &str = diff --git a/src/uu/sleep/src/sleep.rs b/src/uu/sleep/src/sleep.rs index 624e65901..136d92e4d 100644 --- a/src/uu/sleep/src/sleep.rs +++ b/src/uu/sleep/src/sleep.rs @@ -29,7 +29,7 @@ mod options { fn usage() -> String { format!( "{0} {1}[SUFFIX]... \n {0} OPTION", - executable!(), + execution_phrase!(), options::NUMBER ) } diff --git a/src/uu/sort/src/sort.rs b/src/uu/sort/src/sort.rs index 78b6f8b64..049be5352 100644 --- a/src/uu/sort/src/sort.rs +++ b/src/uu/sort/src/sort.rs @@ -52,7 +52,6 @@ use uucore::InvalidEncodingHandling; use crate::tmp_dir::TmpDirWrapper; -const NAME: &str = "sort"; const ABOUT: &str = "Display sorted concatenation of all FILE(s)."; const LONG_HELP_KEYS: &str = "The key format is FIELD[.CHAR][OPTIONS][,FIELD[.CHAR]][OPTIONS]. @@ -1061,7 +1060,7 @@ fn usage() -> String { Write the sorted concatenation of all FILE(s) to standard output. Mandatory arguments for long options are mandatory for short options too. With no FILE, or when FILE is -, read standard input.", - NAME + execution_phrase!() ) } diff --git a/src/uu/split/src/split.rs b/src/uu/split/src/split.rs index bc38818b9..ce21361af 100644 --- a/src/uu/split/src/split.rs +++ b/src/uu/split/src/split.rs @@ -21,8 +21,6 @@ use std::path::Path; use std::{char, fs::remove_file}; use uucore::parse_size::parse_size; -static NAME: &str = "split"; - static OPT_BYTES: &str = "bytes"; static OPT_LINE_BYTES: &str = "line-bytes"; static OPT_LINES: &str = "lines"; @@ -37,7 +35,7 @@ static ARG_INPUT: &str = "input"; static ARG_PREFIX: &str = "prefix"; fn usage() -> String { - format!("{0} [OPTION]... [INPUT [PREFIX]]", NAME) + format!("{0} [OPTION]... [INPUT [PREFIX]]", execution_phrase!()) } fn get_long_usage() -> String { format!( diff --git a/src/uu/stat/src/stat.rs b/src/uu/stat/src/stat.rs index 4a12e4fb7..d3783d725 100644 --- a/src/uu/stat/src/stat.rs +++ b/src/uu/stat/src/stat.rs @@ -883,7 +883,7 @@ impl Stater { } fn usage() -> String { - format!("{0} [OPTION]... FILE...", executable!()) + format!("{0} [OPTION]... FILE...", execution_phrase!()) } fn get_long_usage() -> String { diff --git a/src/uu/stdbuf/src/stdbuf.rs b/src/uu/stdbuf/src/stdbuf.rs index bac5040cf..87e478b73 100644 --- a/src/uu/stdbuf/src/stdbuf.rs +++ b/src/uu/stdbuf/src/stdbuf.rs @@ -48,7 +48,7 @@ mod options { } fn usage() -> String { - format!("{0} OPTION... COMMAND", executable!()) + format!("{0} OPTION... COMMAND", execution_phrase!()) } const STDBUF_INJECT: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/libstdbuf.so")); @@ -161,7 +161,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { 125, "{}\nTry `{} --help` for more information.", e.0, - executable!() + execution_phrase!() ) }); diff --git a/src/uu/sync/src/sync.rs b/src/uu/sync/src/sync.rs index 123167db7..7dd37d780 100644 --- a/src/uu/sync/src/sync.rs +++ b/src/uu/sync/src/sync.rs @@ -160,7 +160,7 @@ mod platform { } fn usage() -> String { - format!("{0} [OPTION]... FILE...", executable!()) + format!("{0} [OPTION]... FILE...", execution_phrase!()) } pub fn uumain(args: impl uucore::Args) -> i32 { diff --git a/src/uu/tee/src/tee.rs b/src/uu/tee/src/tee.rs index 2f1b17ebe..461600003 100644 --- a/src/uu/tee/src/tee.rs +++ b/src/uu/tee/src/tee.rs @@ -33,7 +33,7 @@ struct Options { } fn usage() -> String { - format!("{0} [OPTION]... [FILE]...", executable!()) + format!("{0} [OPTION]... [FILE]...", execution_phrase!()) } pub fn uumain(args: impl uucore::Args) -> i32 { diff --git a/src/uu/timeout/src/timeout.rs b/src/uu/timeout/src/timeout.rs index e0fbe8a54..8b169b5b5 100644 --- a/src/uu/timeout/src/timeout.rs +++ b/src/uu/timeout/src/timeout.rs @@ -23,7 +23,7 @@ use uucore::InvalidEncodingHandling; static ABOUT: &str = "Start COMMAND, and kill it if still running after DURATION."; fn usage() -> String { - format!("{0} [OPTION] DURATION COMMAND...", executable!()) + format!("{0} [OPTION] DURATION COMMAND...", execution_phrase!()) } const ERR_EXIT_STATUS: i32 = 125; diff --git a/src/uu/touch/src/touch.rs b/src/uu/touch/src/touch.rs index bdb65683f..8ddfcfa74 100644 --- a/src/uu/touch/src/touch.rs +++ b/src/uu/touch/src/touch.rs @@ -48,7 +48,7 @@ fn local_tm_to_filetime(tm: time::Tm) -> FileTime { } fn usage() -> String { - format!("{0} [OPTION]... [USER]", executable!()) + format!("{0} [OPTION]... [USER]", execution_phrase!()) } #[uucore_procs::gen_uumain] diff --git a/src/uu/tr/src/tr.rs b/src/uu/tr/src/tr.rs index ddb866393..0a277d663 100644 --- a/src/uu/tr/src/tr.rs +++ b/src/uu/tr/src/tr.rs @@ -229,7 +229,7 @@ fn translate_input( } fn usage() -> String { - format!("{} [OPTION]... SET1 [SET2]", executable!()) + format!("{} [OPTION]... SET1 [SET2]", execution_phrase!()) } fn get_long_usage() -> String { @@ -264,7 +264,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { if sets.is_empty() { show_error!( "missing operand\nTry `{} --help` for more information.", - executable!() + execution_phrase!() ); return 1; } @@ -273,7 +273,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { show_error!( "missing operand after '{}'\nTry `{} --help` for more information.", sets[0], - executable!() + execution_phrase!() ); return 1; } diff --git a/src/uu/truncate/src/truncate.rs b/src/uu/truncate/src/truncate.rs index c5f9fb5b7..fdcff3fd5 100644 --- a/src/uu/truncate/src/truncate.rs +++ b/src/uu/truncate/src/truncate.rs @@ -64,7 +64,7 @@ pub mod options { } fn usage() -> String { - format!("{0} [OPTION]... [FILE]...", executable!()) + format!("{0} [OPTION]... [FILE]...", execution_phrase!()) } fn get_long_usage() -> String { diff --git a/src/uu/tty/src/tty.rs b/src/uu/tty/src/tty.rs index df6c43a27..284916050 100644 --- a/src/uu/tty/src/tty.rs +++ b/src/uu/tty/src/tty.rs @@ -24,7 +24,7 @@ mod options { } fn usage() -> String { - format!("{0} [OPTION]...", executable!()) + format!("{0} [OPTION]...", execution_phrase!()) } pub fn uumain(args: impl uucore::Args) -> i32 { diff --git a/src/uu/uname/src/uname.rs b/src/uu/uname/src/uname.rs index 2b16c85ec..b15d950bf 100644 --- a/src/uu/uname/src/uname.rs +++ b/src/uu/uname/src/uname.rs @@ -50,7 +50,7 @@ const HOST_OS: &str = "Fuchsia"; const HOST_OS: &str = "Redox"; pub fn uumain(args: impl uucore::Args) -> i32 { - let usage = format!("{} [OPTION]...", executable!()); + let usage = format!("{} [OPTION]...", execution_phrase!()); let matches = uu_app().usage(&usage[..]).get_matches_from(args); let uname = return_if_err!(1, PlatformInfo::new()); diff --git a/src/uu/uniq/src/uniq.rs b/src/uu/uniq/src/uniq.rs index fd8b4019b..10cb7a4ce 100644 --- a/src/uu/uniq/src/uniq.rs +++ b/src/uu/uniq/src/uniq.rs @@ -222,7 +222,7 @@ fn opt_parsed(opt_name: &str, matches: &ArgMatches) -> Option { } fn usage() -> String { - format!("{0} [OPTION]... [INPUT [OUTPUT]]...", executable!()) + format!("{0} [OPTION]... [INPUT [OUTPUT]]...", execution_phrase!()) } fn get_long_usage() -> String { diff --git a/src/uu/unlink/src/unlink.rs b/src/uu/unlink/src/unlink.rs index 0601b3e54..182729fd4 100644 --- a/src/uu/unlink/src/unlink.rs +++ b/src/uu/unlink/src/unlink.rs @@ -23,7 +23,7 @@ static ABOUT: &str = "Unlink the file at [FILE]."; static OPT_PATH: &str = "FILE"; fn usage() -> String { - format!("{} [OPTION]... FILE", executable!()) + format!("{} [OPTION]... FILE", execution_phrase!()) } pub fn uumain(args: impl uucore::Args) -> i32 { @@ -44,13 +44,13 @@ pub fn uumain(args: impl uucore::Args) -> i32 { crash!( 1, "missing operand\nTry `{0} --help` for more information.", - executable!() + execution_phrase!() ); } else if paths.len() > 1 { crash!( 1, "extra operand: '{1}'\nTry `{0} --help` for more information.", - executable!(), + execution_phrase!(), paths[1] ); } diff --git a/src/uu/uptime/src/uptime.rs b/src/uu/uptime/src/uptime.rs index 33f3ec965..b19566ec3 100644 --- a/src/uu/uptime/src/uptime.rs +++ b/src/uu/uptime/src/uptime.rs @@ -33,7 +33,7 @@ extern "C" { } fn usage() -> String { - format!("{0} [OPTION]...", executable!()) + format!("{0} [OPTION]...", execution_phrase!()) } pub fn uumain(args: impl uucore::Args) -> i32 { diff --git a/src/uu/users/src/users.rs b/src/uu/users/src/users.rs index 3f081f891..7aed00507 100644 --- a/src/uu/users/src/users.rs +++ b/src/uu/users/src/users.rs @@ -19,7 +19,7 @@ static ABOUT: &str = "Print the user names of users currently logged in to the c static ARG_FILES: &str = "files"; fn usage() -> String { - format!("{0} [FILE]", executable!()) + format!("{0} [FILE]", execution_phrase!()) } fn get_long_usage() -> String { diff --git a/src/uu/wc/src/wc.rs b/src/uu/wc/src/wc.rs index e21eb0b7e..3077d31d9 100644 --- a/src/uu/wc/src/wc.rs +++ b/src/uu/wc/src/wc.rs @@ -99,7 +99,7 @@ fn usage() -> String { format!( "{0} [OPTION]... [FILE]... With no FILE, or when FILE is -, read standard input.", - executable!() + execution_phrase!() ) } diff --git a/src/uu/who/src/who.rs b/src/uu/who/src/who.rs index 558d42f1b..59e8b7c36 100644 --- a/src/uu/who/src/who.rs +++ b/src/uu/who/src/who.rs @@ -45,7 +45,7 @@ static RUNLEVEL_HELP: &str = "print current runlevel"; static RUNLEVEL_HELP: &str = "print current runlevel (This is meaningless on non Linux)"; fn usage() -> String { - format!("{0} [OPTION]... [ FILE | ARG1 ARG2 ]", executable!()) + format!("{0} [OPTION]... [ FILE | ARG1 ARG2 ]", execution_phrase!()) } fn get_long_usage() -> String { diff --git a/src/uucore/src/lib/macros.rs b/src/uucore/src/lib/macros.rs index 36336a24d..df3834f7e 100644 --- a/src/uucore/src/lib/macros.rs +++ b/src/uucore/src/lib/macros.rs @@ -125,7 +125,7 @@ macro_rules! show_usage_error( ($($args:tt)+) => ({ eprint!("{}: ", $crate::util_name!()); eprintln!($($args)+); - eprintln!("Try `{:?} --help` for more information.", $crate::executable!()); + eprintln!("Try `{} --help` for more information.", $crate::execution_phrase!()); }) ); diff --git a/src/uucore_procs/src/lib.rs b/src/uucore_procs/src/lib.rs index 2467ce2c7..74ac60220 100644 --- a/src/uucore_procs/src/lib.rs +++ b/src/uucore_procs/src/lib.rs @@ -104,7 +104,7 @@ pub fn gen_uumain(_args: TokenStream, stream: TokenStream) -> TokenStream { show_error!("{}", s); } if e.usage() { - eprintln!("Try `{} --help` for more information.", executable!()); + eprintln!("Try `{} --help` for more information.", execution_phrase!()); } e.code() }