shell
This commit is contained in:
parent
05b1aca6be
commit
f54ef9c06f
2 changed files with 1 additions and 41 deletions
|
@ -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
|
||||
|
|
40
src/Which.fs
40
src/Which.fs
|
@ -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."
|
Loading…
Reference in a new issue