~emersion/mrsh-dev

Seedo Paul: 1
 shift: fix logic

 1 files changed, 8 insertions(+), 6 deletions(-)
#939440 alpine.yml success
#939441 archlinux.yml success
#939442 freebsd.yml success
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/38960/mbox | git am -3
Learn more about email & git

[PATCH mrsh] shift: fix logic Export this patch

---
 builtin/shift.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/builtin/shift.c b/builtin/shift.c
index 5c582fc..c572f6d 100644
--- a/builtin/shift.c
@@ -40,13 +40,15 @@ int builtin_shift(struct mrsh_state *state, int argc, char *argv[]) {
		}
		return 1;
	}
	for (int i = 1, j = n + 1; j < state->frame->argc; ++i, ++j) {
		if (j <= state->frame->argc - n) {
			state->frame->argv[i] = state->frame->argv[j];
		} else {
			free(state->frame->argv[i]);
		}

	for (int i = 1; i < n; i++) {
		free(state->frame->argv[i]);
	}

	for (int i = 0, j = n; j < state->frame->argc; i++, j++) {
		state->frame->argv[i] = state->frame->argv[j];
	}

	state->frame->argc -= n;
	return 0;
}
-- 
2.39.1
mrsh/patches: SUCCESS in 47s

[shift: fix logic][0] from [Seedo Paul][1]

[0]: https://lists.sr.ht/~emersion/mrsh-dev/patches/38960
[1]: mailto:seedoeldhopaul@gmail.com

✓ #939441 SUCCESS mrsh/patches/archlinux.yml https://builds.sr.ht/~emersion/job/939441
✓ #939442 SUCCESS mrsh/patches/freebsd.yml   https://builds.sr.ht/~emersion/job/939442
✓ #939440 SUCCESS mrsh/patches/alpine.yml    https://builds.sr.ht/~emersion/job/939440