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,13 +99,15 @@ fn install(confirm: bool) {
|
|||
// - Install: Manpages (build via build.rs)
|
||||
// - Don't install: __fish_build_paths.fish.in
|
||||
if confirm {
|
||||
eprintln!(
|
||||
"This will write fish's data files to '{}'.\n\
|
||||
Please enter 'yes' to continue.",
|
||||
dir.display()
|
||||
);
|
||||
eprint!("> ");
|
||||
let _ = stderr().flush();
|
||||
if isatty(libc::STDIN_FILENO) {
|
||||
eprintln!(
|
||||
"This will write fish's data files to '{}'.\n\
|
||||
Please enter 'yes' to continue.",
|
||||
dir.display()
|
||||
);
|
||||
eprint!("> ");
|
||||
let _ = stderr().flush();
|
||||
}
|
||||
|
||||
let mut input = String::new();
|
||||
if let Err(error) = stdin().read_line(&mut input) {
|
||||
|
@ -113,7 +115,7 @@ fn install(confirm: bool) {
|
|||
}
|
||||
|
||||
if input != "yes\n" {
|
||||
eprintln!("Exiting without writing any files\n");
|
||||
eprintln!("Exiting without writing any files");
|
||||
std::process::exit(1);
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue
Block a user