~sircmpwn/mrsh

dd0a98834422aeca30fe5e7052251c335ccfcfe9 — Simon Ser 6 months ago 2d5d78b
shell: fix pipeline bangs
2 files changed, 7 insertions(+), 3 deletions(-)

M shell/task/pipeline.c
M test/pipeline.sh
M shell/task/pipeline.c => shell/task/pipeline.c +5 -1
@@ 23,7 23,11 @@ int run_pipeline(struct context *ctx, struct mrsh_pipeline *pl) {

	assert(pl->commands.len > 0);
	if (pl->commands.len == 1) {
		return run_command(&child_ctx, pl->commands.data[0]);
		int ret = run_command(&child_ctx, pl->commands.data[0]);
		if (pl->bang && ret >= 0) {
			ret = !ret;
		}
		return ret;
	}

	struct mrsh_array procs = {0};

M test/pipeline.sh => test/pipeline.sh +2 -2
@@ 10,8 10,8 @@ echo >&2 "Pipeline with 3 commands"
echo "a b c d" | sed s/b/B/ | sed s/c/C/

#echo >&2 "Pipeline with bang"
#! false
#echo $?
! false
echo $?

# https://github.com/emersion/mrsh/issues/100
#echo >&2 "Pipeline with subshell"