mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-30 04:27:45 +00:00
Add macro to properly find program name.
This commit is contained in:
parent
b90d253584
commit
58d6add8d1
1 changed files with 15 additions and 3 deletions
|
@ -7,10 +7,22 @@
|
||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! executable(
|
||||||
|
() => ({
|
||||||
|
let module = module_path!();
|
||||||
|
if &module[0..3] == "uu_" {
|
||||||
|
&module[3..]
|
||||||
|
} else {
|
||||||
|
module
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! show_error(
|
macro_rules! show_error(
|
||||||
($($args:tt)+) => ({
|
($($args:tt)+) => ({
|
||||||
pipe_write!(&mut ::std::io::stderr(), "{}: error: ", module_path!());
|
pipe_write!(&mut ::std::io::stderr(), "{}: error: ", executable!());
|
||||||
pipe_writeln!(&mut ::std::io::stderr(), $($args)+);
|
pipe_writeln!(&mut ::std::io::stderr(), $($args)+);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
@ -18,7 +30,7 @@ macro_rules! show_error(
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! show_warning(
|
macro_rules! show_warning(
|
||||||
($($args:tt)+) => ({
|
($($args:tt)+) => ({
|
||||||
pipe_write!(&mut ::std::io::stderr(), "{}: warning: ", module_path!());
|
pipe_write!(&mut ::std::io::stderr(), "{}: warning: ", executable!());
|
||||||
pipe_writeln!(&mut ::std::io::stderr(), $($args)+);
|
pipe_writeln!(&mut ::std::io::stderr(), $($args)+);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
@ -26,7 +38,7 @@ macro_rules! show_warning(
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! show_info(
|
macro_rules! show_info(
|
||||||
($($args:tt)+) => ({
|
($($args:tt)+) => ({
|
||||||
pipe_write!(&mut ::std::io::stderr(), "{}: ", module_path!());
|
pipe_write!(&mut ::std::io::stderr(), "{}: ", executable!());
|
||||||
pipe_writeln!(&mut ::std::io::stderr(), $($args)+);
|
pipe_writeln!(&mut ::std::io::stderr(), $($args)+);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue