This is specified by POSIX and easily implemented.
---
builtin/set.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/builtin/set.c b/builtin/set.c
index c3ad0e6..2f7c698 100644
--- a/builtin/set.c
@@ -160,6 +160,13 @@ static int set(struct mrsh_state *state, int argc, char *argv[],
init_args->command_str = argv[i + 1];
++i;
break;
+ case 'i':
+ if (init_args == NULL) {
+ fprintf(stderr, set_usage);
+ return 1;
+ }
+ state->interactive = argv[i][0] == '-';
+ break;
case 's':
if (init_args == NULL) {
fprintf(stderr, set_usage);
@@ -239,8 +246,11 @@ int mrsh_process_args(struct mrsh_state *state, struct mrsh_init_args *init_args
return ret;
}
- state->interactive = isatty(priv->term_fd) &&
- init_args->command_str == NULL && init_args->command_file == NULL;
+ if (!state->interactive) {
+ state->interactive = isatty(priv->term_fd) &&
+ init_args->command_str == NULL &&
+ init_args->command_file == NULL;
+ }
if (state->interactive && !(populated_opts & MRSH_OPT_MONITOR)) {
state->options |= MRSH_OPT_MONITOR;
}
--
2.34.1
On Tuesday, February 1st, 2022 at 15:51, Victor Westerhuis <victor@westerhu.is> wrote:
> This is specified by POSIX
I don't see where, can you give a reference?
Additionally, I don't think we can switch the interactive mode at runtime
easily.