1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//! Running a script.
//!
//! On Unix the child *replaces* `opi` through `exec`, rather than being
//! supervised by it. That settles the awkward parts of running a long-lived
//! process for free: `Ctrl-C` reaches the dev server rather than killing the
//! wrapper and orphaning it, stdio is the child's own (so a dev server's
//! coloured output and prompts are untouched), and the exit code is the
//! child's, so `opi build && …` behaves in a shell chain.
//!
//! It also matches the intended behaviour: once a script runs, `opi` is done
//! and does not return to its list.
//!
//! Windows has no `exec`, which is why `opi` is Unix-only. Supervising the
//! child instead would mean a second execution model that nothing here tests,
//! and a `Ctrl-C` that kills the wrapper rather than the dev server.
use io;
use Command;
use cratePackageManager;
use crate;
/// Runs `script` through `manager`, forwarding `args` to it.
///
/// Returns only when the command could not be started at all; on success this
/// process has been replaced by the script.