~emersion/mrsh-dev

Add -i option v2 PROPOSED

Victor Westerhuis: 1
 Add -i option

 1 files changed, 12 insertions(+), 2 deletions(-)
Of course: 
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/sh.html under 
OPTIONS.

It does not require -i to be settable at runtime, if I'm reading 
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#set 
correctly, so that should be OK.
-- 
Victor Westerhuis <victor@westerhu.is>
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~emersion/mrsh-dev/patches/28918/mbox | git am -3
Learn more about email & git

[PATCH v2] Add -i option Export this patch

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
> 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.