mirror of
https://github.com/nushell/nushell.git
synced 2025-05-02 17:14:27 +02:00
Merge pull request #706 from landaire/ctrlc_config
feat(cli): add `ctrlc_exit` config option
This commit is contained in:
commit
7113c702ff
12
src/cli.rs
12
src/cli.rs
@ -406,6 +406,18 @@ pub async fn cli() -> Result<(), Box<dyn Error>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
LineResult::CtrlC => {
|
LineResult::CtrlC => {
|
||||||
|
let config_ctrlc_exit = config::config(Tag::unknown())?
|
||||||
|
.get("ctrlc_exit")
|
||||||
|
.map(|s| match s.as_string().unwrap().as_ref() {
|
||||||
|
"true" => true,
|
||||||
|
_ => false,
|
||||||
|
})
|
||||||
|
.unwrap_or(false); // default behavior is to allow CTRL-C spamming similar to other shells
|
||||||
|
|
||||||
|
if !config_ctrlc_exit {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if ctrlcbreak {
|
if ctrlcbreak {
|
||||||
let _ = rl.save_history(&History::path());
|
let _ = rl.save_history(&History::path());
|
||||||
std::process::exit(0);
|
std::process::exit(0);
|
||||||
|
Loading…
Reference in New Issue
Block a user