mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-22 14:29:16 +08:00
Exit if --no-execute is enabled don't interactively read from the terminal
Don't go into implicit interactive mode without ever executing anything - not even `exit` or reacting to ctrl-d. That just renders the shell useless and unquittable.
This commit is contained in:
parent
eb43fc83c5
commit
cf8219e3ce
|
@ -503,6 +503,10 @@ int main(int argc, char **argv) {
|
|||
parser.libdata().exit_current_script = false;
|
||||
} else if (my_optind == argc) {
|
||||
// Implicitly interactive mode.
|
||||
if (opts.no_exec && isatty(STDIN_FILENO)) {
|
||||
FLOGF(error, L"no-execute mode enabled and no script given. Exiting");
|
||||
return EXIT_FAILURE; // above line should always exit
|
||||
}
|
||||
res = reader_read(parser, STDIN_FILENO, {});
|
||||
} else {
|
||||
const char *file = *(argv + (my_optind++));
|
||||
|
|
|
@ -53,3 +53,6 @@ $fish -c 'string escape y$argv' -c 'string escape x$argv' 1 2 3
|
|||
# CHECK: x1
|
||||
# CHECK: x2
|
||||
# CHECK: x3
|
||||
|
||||
# Should just do nothing.
|
||||
$fish --no-execute
|
||||
|
|
|
@ -51,5 +51,8 @@ expect_prompt("hoge")
|
|||
sendline("echo hoge >| \n cat")
|
||||
expect_prompt("hoge")
|
||||
|
||||
sendline("$fish --no-execute 2>&1")
|
||||
expect_prompt("error: no-execute mode enabled and no script given. Exiting")
|
||||
|
||||
sendline("source; or echo failed")
|
||||
expect_prompt("failed")
|
||||
|
|
Loading…
Reference in New Issue
Block a user