mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
refactor/uucore ~ align return values for executable/util macros
This commit is contained in:
committed by
Michael Debertol
parent
eb13533e4e
commit
69ce4dc8e5
@@ -20,7 +20,7 @@ macro_rules! executable(
|
||||
let exe = match $crate::executable_os!().to_str() {
|
||||
// * UTF-8
|
||||
Some(s) => s.to_string(),
|
||||
// * "lossless" debug format if `executable_os!()` is not well-formed UTF-8
|
||||
// * "lossless" debug format (if/when `executable_os!()` is not well-formed UTF-8)
|
||||
None => format!("{:?}", $crate::executable_os!())
|
||||
};
|
||||
&exe.to_owned()
|
||||
@@ -31,7 +31,14 @@ macro_rules! executable(
|
||||
#[macro_export]
|
||||
macro_rules! executable_name(
|
||||
() => ({
|
||||
&std::path::Path::new($crate::executable_os!()).file_stem().unwrap().to_string_lossy()
|
||||
let stem = &std::path::Path::new($crate::executable_os!()).file_stem().unwrap().to_owned();
|
||||
let exe = match stem.to_str() {
|
||||
// * UTF-8
|
||||
Some(s) => s.to_string(),
|
||||
// * "lossless" debug format (if/when `executable_os!()` is not well-formed UTF-8)
|
||||
None => format!("{:?}", stem)
|
||||
};
|
||||
&exe.to_owned()
|
||||
})
|
||||
);
|
||||
|
||||
@@ -40,11 +47,12 @@ macro_rules! executable_name(
|
||||
macro_rules! util_name(
|
||||
() => ({
|
||||
let crate_name = env!("CARGO_PKG_NAME");
|
||||
if crate_name.starts_with("uu_") {
|
||||
let name = if crate_name.starts_with("uu_") {
|
||||
&crate_name[3..]
|
||||
} else {
|
||||
&crate_name
|
||||
}
|
||||
crate_name
|
||||
};
|
||||
&name.to_owned()
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user