From a05ad4c25fc2ee04b471fed37566c59fa242673c Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Sat, 21 Jan 2023 09:21:20 +0100 Subject: [PATCH] fix program filename check --- src/main.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 1652d66..dafc099 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,7 +4,12 @@ use std::{env, ffi::OsString, io, os::unix::process::CommandExt, process::Comman use syslog::{unix, Facility::LOG_AUTH, Formatter3164}; fn main() -> io::Result<()> { - if env::args_os().nth(0).unwrap() != "🥺" { + let progName = std::env::current_exe() + .ok() + .and_then(|pb| pb.file_name().map(|s| s.to_os_string())) + .and_then(|s| s.into_string().ok()); + + if progName.unwrap() != "🥺" { eprintln!( "error: called 🥺 with name {:?}", env::args_os().nth(0).unwrap()