blob: a68c6b0d1ec56d2c098851895d09b7c1eea5dd31 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
(*─────────────────────────────────────────────────────────────────────────────┐
│ SPDX-FileCopyrightText: 2025 toastal <https://toast.al/contact/> │
│ SPDX-License-Identifier: LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception │
└─────────────────────────────────────────────────────────────────────────────*)
let find () =
match Sys.getenv_opt "VISUAL" with
| Some v -> v
| None ->
match Sys.getenv_opt "EDITOR" with
| Some e -> e
| None -> "vi"
let run_on file =
match find () with
| ed when String.contains ed ' ' ->
Unix.execvp "/bin/sh" [|"/bin/sh"; "-c"; ed ^ " " ^ Filename.quote file|]
| ed ->
Unix.execvp ed [|ed; file|]
|