Skip to content

Commit 4188ee1

Browse files
committed
agent: deal with a qualified argv[0]
1 parent e727bf8 commit 4188ee1

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

agent/src/main.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -924,9 +924,22 @@ async fn cmd_run(mut l: Level<()>) -> Result<()> {
924924

925925
#[tokio::main]
926926
async fn main() -> Result<()> {
927-
match std::env::args().next().as_deref() {
927+
let cmdname = std::env::args()
928+
.next()
929+
.as_deref()
930+
.map(|s| {
931+
let path = PathBuf::from(s);
932+
path.file_name()
933+
.map(|s| s.to_str())
934+
.flatten()
935+
.map(|s| Some(s.to_string()))
936+
.flatten()
937+
})
938+
.flatten();
939+
940+
match cmdname.as_deref() {
928941
None => bail!("could not determine executable name?"),
929-
Some("bmat") => {
942+
Some(CONTROL_PROGRAM) => {
930943
/*
931944
* This is the in-job control entrypoint to be invoked by job
932945
* programs.

0 commit comments

Comments
 (0)