~emersion/mrsh-dev

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
2 2

[PATCH v2] Add -i option

Victor Westerhuis <victor@westerhu.is>
Details
Message ID
<20220201145132.67869-1-victor@westerhu.is>
DKIM signature
missing
Download raw message
Patch: +12 -2
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
Details
Message ID
<fFwRJpRPVy6RcO6GQ3KZ8aPzg_VrBLGNWTNAvOEobXyg2yTTXstRRWw2hX6j_1hMv3KVu0SRlpZoSUs896GgzxjsDOxEEmPIurAdHvhvKpw=@emersion.fr>
In-Reply-To
<20220201145132.67869-1-victor@westerhu.is> (view parent)
DKIM signature
missing
Download raw message
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.
Victor Westerhuis <victor@westerhu.is>
Details
Message ID
<31b3ed41-2d84-deb9-ad36-2ae7898eb115@westerhu.is>
In-Reply-To
<fFwRJpRPVy6RcO6GQ3KZ8aPzg_VrBLGNWTNAvOEobXyg2yTTXstRRWw2hX6j_1hMv3KVu0SRlpZoSUs896GgzxjsDOxEEmPIurAdHvhvKpw=@emersion.fr> (view parent)
DKIM signature
missing
Download raw message
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>
Reply to thread Export thread (mbox)