mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-25 09:39:52 +08:00
Only print prompt if stdin is a tty
If you do use `--install` without =noconfirm via e.g. `echo yes | fish --install`, this will avoid the prompt. It will still expect to read a "yes" and error out otherwise.
This commit is contained in:
parent
2c7d2097be
commit
0e6915d522
|
@ -99,6 +99,7 @@ fn install(confirm: bool) {
|
||||||
// - Install: Manpages (build via build.rs)
|
// - Install: Manpages (build via build.rs)
|
||||||
// - Don't install: __fish_build_paths.fish.in
|
// - Don't install: __fish_build_paths.fish.in
|
||||||
if confirm {
|
if confirm {
|
||||||
|
if isatty(libc::STDIN_FILENO) {
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"This will write fish's data files to '{}'.\n\
|
"This will write fish's data files to '{}'.\n\
|
||||||
Please enter 'yes' to continue.",
|
Please enter 'yes' to continue.",
|
||||||
|
@ -106,6 +107,7 @@ fn install(confirm: bool) {
|
||||||
);
|
);
|
||||||
eprint!("> ");
|
eprint!("> ");
|
||||||
let _ = stderr().flush();
|
let _ = stderr().flush();
|
||||||
|
}
|
||||||
|
|
||||||
let mut input = String::new();
|
let mut input = String::new();
|
||||||
if let Err(error) = stdin().read_line(&mut input) {
|
if let Err(error) = stdin().read_line(&mut input) {
|
||||||
|
@ -113,7 +115,7 @@ fn install(confirm: bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if input != "yes\n" {
|
if input != "yes\n" {
|
||||||
eprintln!("Exiting without writing any files\n");
|
eprintln!("Exiting without writing any files");
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user