mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-17 04:12:45 +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;
|
parser.libdata().exit_current_script = false;
|
||||||
} else if (my_optind == argc) {
|
} else if (my_optind == argc) {
|
||||||
// Implicitly interactive mode.
|
// 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, {});
|
res = reader_read(parser, STDIN_FILENO, {});
|
||||||
} else {
|
} else {
|
||||||
const char *file = *(argv + (my_optind++));
|
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: x1
|
||||||
# CHECK: x2
|
# CHECK: x2
|
||||||
# CHECK: x3
|
# CHECK: x3
|
||||||
|
|
||||||
|
# Should just do nothing.
|
||||||
|
$fish --no-execute
|
||||||
|
|
|
@ -51,5 +51,8 @@ expect_prompt("hoge")
|
||||||
sendline("echo hoge >| \n cat")
|
sendline("echo hoge >| \n cat")
|
||||||
expect_prompt("hoge")
|
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")
|
sendline("source; or echo failed")
|
||||||
expect_prompt("failed")
|
expect_prompt("failed")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user