diff options
author | KOVACS Krisztian <kkovaacs@gmail.com> | 2021-02-02 20:58:18 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-02 14:58:18 -0500 |
commit | c9c3455e23321212b0ece0ba49d5e412beef06db (patch) | |
tree | e18c50473db6ef5a5d3027d307c9090fa7d67749 /src/utils.rs | |
parent | 22dc8b842e721c440aa98035dd2dff30c7fe6497 (diff) |
fix(windows): fix windows terminal ANSI escape sequences (#2258)
* fix(windows): don't inherit stdin when executing commands
On Windows, inheriting stdin from starship might lead to leaking the
console reference to the command we're executing. `id.exe` supplied with
Git has been observed to disable the ENABLE_VIRTUAL_TERMINAL_PROCESSING
console flag if it inherits stdin -- leading to Windows Terminal not
processing ANSI escape sequences.
This change fixes #2254 by explicitly disabling stdin inheritance.
The fix was suggested by David Knaack.
* fix(username): don't call `id -u` on Windows
This was done to check if user is root by comparing the UID to 0. Windows
does not have a concept of UID 0 anyway, so it's pointless to call `id.exe`
(which is installed with MSYS2 or Git, for example).
Diffstat (limited to 'src/utils.rs')
-rw-r--r-- | src/utils.rs | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/utils.rs b/src/utils.rs index 2ab34a88f..6d5612222 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -277,6 +277,7 @@ fn internal_exec_cmd(cmd: &str, args: &[&str]) -> Option<CommandOutput> { .args(args) .stderr(Stdio::piped()) .stdout(Stdio::piped()) + .stdin(Stdio::null()) .spawn() { Ok(process) => process, |