diff --git a/src/Cron.fs b/src/Cron.fs index 8be832b..d2e1a2b 100644 --- a/src/Cron.fs +++ b/src/Cron.fs @@ -84,7 +84,7 @@ let private parse now (db: Requirements) = else Ok (splitted.[0], splitted.[1])) - let executable = Which.which db.executable + let executable = Shell.which db.executable let workdir = Path.of_string db.workdir |> Result.bind FileSystem.resolve Result.zip when_ env diff --git a/src/Which.fs b/src/Which.fs deleted file mode 100644 index 3975db5..0000000 --- a/src/Which.fs +++ /dev/null @@ -1,40 +0,0 @@ -module Bidello.Which - -open Sheller -open Pentole.Path - -let which (executable: string) = - let possible_shells = [ - "/bin/sh" - "/bin/bash" - "/bin/dash" - "/bin/fish" - "/usr/bin/sh" - "/usr/bin/bash" - "/usr/bin/dash" - "/usr/bin/fish" - ] - - let shell = List.tryFind (fun sh -> sh |> Path.of_string |> Result.isOk) possible_shells - - if shell |> Option.isSome then - let rc = - Builder - .UseShell(shell.Value) - .UseExecutable("which") - .WithArgument(executable) - .UseNoThrow() - .ExecuteAsync () - |> Async.AwaitTask - |> Async.RunSynchronously - if rc.ExitCode = 0 then - rc.StandardOutput - |> _.Trim() - |> Path.of_string - elif rc.ExitCode = 1 then - Error $"Can't find executable path for \"{executable}\"." - else - rc.StandardError - |> Error - else - Error "Can't find the system shell. Check your system $PATH."