04937ee39cf2003240a68867f69180cb44d8b0f8 — Drew DeVault 3 months ago a263f96
Replace EXIT_* constants with integers
M builtin/alias.c => builtin/alias.c +4 -4
@@ 21,12 21,12 @@ if (mrsh_getopt(argc, argv, ":") != -1) {
  		fprintf(stderr, "alias: unknown option -- %c\n", mrsh_optopt);
  		fprintf(stderr, alias_usage);
- 		return EXIT_FAILURE;
+ 		return 1;
  	}
  
  	if (mrsh_optind == argc) {
  		mrsh_hashtable_for_each(&state->aliases, print_alias_iterator, NULL);
- 		return EXIT_SUCCESS;
+ 		return 0;
  	}
  
  	for (int i = mrsh_optind; i < argc; ++i) {


@@ 42,7 42,7 @@ const char *value = mrsh_hashtable_get(&state->aliases, alias);
  			if (value == NULL) {
  				fprintf(stderr, "%s: %s not found\n", argv[0], alias);
- 				return EXIT_FAILURE;
+ 				return 1;
  			}
  
  			printf("%s=", alias);


@@ 51,5 51,5 @@ }
  	}
  
- 	return EXIT_SUCCESS;
+ 	return 0;
  }

M builtin/cd.c => builtin/cd.c +10 -10
@@ 17,17 17,17 @@ if (chdir(path) != 0) {
  		// TODO make better error messages
  		fprintf(stderr, "cd: %s\n", strerror(errno));
- 		return EXIT_FAILURE;
+ 		return 1;
  	}
  	char cwd[PATH_MAX];
  	if (getcwd(cwd, PATH_MAX) == NULL) {
  		fprintf(stderr, "cd: Cannot set new PWD as the path "
  			"is too long\n");
- 		return EXIT_FAILURE;
+ 		return 1;
  	}
  	mrsh_env_set(state, "OLDPWD", oldPWD, MRSH_VAR_ATTRIB_NONE);
  	mrsh_env_set(state, "PWD", cwd, MRSH_VAR_ATTRIB_EXPORT);
- 	return EXIT_SUCCESS;
+ 	return 0;
  }
  
  static int isdir(char *path) {


@@ 45,11 45,11 @@ case 'P':
  			// TODO implement `-L` and `-P`
  			fprintf(stderr, "cd: `-L` and `-P` not yet implemented\n");
- 			return EXIT_FAILURE;
+ 			return 1;
  		default:
  			fprintf(stderr, "cd: unknown option -- %c\n", mrsh_optopt);
  			fprintf(stderr, cd_usage);
- 			return EXIT_FAILURE;
+ 			return 1;
  		}
  	}
  


@@ 60,7 60,7 @@ }
  		fprintf(stderr, "cd: No arguments were given and $HOME "
  			"is not defined.\n");
- 		return EXIT_FAILURE;
+ 		return 1;
  	}
  
  	char *curpath = argv[mrsh_optind];


@@ 71,22 71,22 @@ const char *pwd = mrsh_env_get(state, "PWD", NULL);
  		if (!pwd) {
  			fprintf(stderr, "cd: PWD is not set\n");
- 			return EXIT_FAILURE;
+ 			return 1;
  		}
  		if (!oldpwd) {
  			fprintf(stderr, "cd: OLDPWD is not set\n");
- 			return EXIT_FAILURE;
+ 			return 1;
  		}
  		if (chdir(oldpwd) != 0) {
  			fprintf(stderr, "cd: %s\n", strerror(errno));
- 			return EXIT_FAILURE;
+ 			return 1;
  		}
  		char *_pwd = strdup(pwd);
  		puts(oldpwd);
  		mrsh_env_set(state, "PWD", oldpwd, MRSH_VAR_ATTRIB_EXPORT);
  		mrsh_env_set(state, "OLDPWD", _pwd, MRSH_VAR_ATTRIB_NONE);
  		free(_pwd);
- 		return EXIT_SUCCESS;
+ 		return 0;
  	}
  	// $CDPATH
  	if (curpath[0] != '/' && strncmp(curpath, "./", 2) != 0 &&

M builtin/colon.c => builtin/colon.c +1 -1
@@ 3,5 3,5 @@ #include "builtin.h"
  
  int builtin_colon(struct mrsh_state *state, int argc, char *argv[]) {
- 	return EXIT_SUCCESS; // This builtin does not do anything
+ 	return 0; // This builtin does not do anything
  }

M builtin/dot.c => builtin/dot.c +7 -7
@@ 16,16 16,16 @@ int builtin_dot(struct mrsh_state *state, int argc, char *argv[]) {
  	if (argc != 2) {
  		fprintf(stderr, source_usage);
- 		return EXIT_FAILURE;
+ 		return 1;
  	}
  
  	const char *path = expand_path(state, argv[1], false);
  	if (!path) {
  		fprintf(stderr, "%s: not found\n", argv[1]);
  		if (!state->interactive) {
- 			state->exit = EXIT_FAILURE;
+ 			state->exit = 1;
  		}
- 		return EXIT_FAILURE;
+ 		return 1;
  	}
  
  	int fd = open(path, O_RDONLY | O_CLOEXEC);


@@ 45,9 45,9 @@ if (err_msg != NULL) {
  			fprintf(stderr, "%s %d:%d: %s\n",
  				argv[1], err_pos.line, err_pos.column, err_msg);
- 			ret = EXIT_FAILURE;
+ 			ret = 1;
  		} else {
- 			ret = EXIT_SUCCESS;
+ 			ret = 0;
  		}
  	} else {
  		ret = mrsh_run_program(state, program);


@@ 60,7 60,7 @@   error:
  	if (!state->interactive) {
- 		state->exit = EXIT_FAILURE;
+ 		state->exit = 1;
  	}
- 	return EXIT_FAILURE;
+ 	return 1;
  }

M builtin/eval.c => builtin/eval.c +3 -3
@@ 15,7 15,7 @@ int builtin_eval(struct mrsh_state *state, int argc, char *argv[]) {
  	if (argc == 1) {
  		fprintf(stderr, eval_usage);
- 		return EXIT_FAILURE;
+ 		return 1;
  	}
  
  	struct mrsh_buffer buf = {0};


@@ 38,9 38,9 @@ if (err_msg != NULL) {
  			fprintf(stderr, "%s %d:%d: %s\n",
  				argv[1], err_pos.line, err_pos.column, err_msg);
- 			ret = EXIT_FAILURE;
+ 			ret = 1;
  		} else {
- 			ret = EXIT_SUCCESS;
+ 			ret = 0;
  		}
  	} else {
  		ret = mrsh_run_program(state, program);

M builtin/exit.c => builtin/exit.c +3 -3
@@ 9,7 9,7 @@ int builtin_exit(struct mrsh_state *state, int argc, char *argv[]) {
  	if (argc > 2) {
  		fprintf(stderr, exit_usage);
- 		return EXIT_FAILURE;
+ 		return 1;
  	}
  
  	int status = 0;


@@ 20,11 20,11 @@ if (endptr[0] != '\0' || errno != 0 ||
  				status_long < 0 || status_long > 255) {
  			fprintf(stderr, exit_usage);
- 			return EXIT_FAILURE;
+ 			return 1;
  		}
  		status = (int)status_long;
  	}
  
  	state->exit = status;
- 	return EXIT_SUCCESS;
+ 	return 0;
  }

M builtin/export.c => builtin/export.c +4 -4
@@ 15,7 15,7 @@   	if (argc < 2) {
  		fprintf(stderr, export_usage, argv[0]);
- 		return EXIT_FAILURE;
+ 		return 1;
  	} else if (argc == 2 && strcmp(argv[1], "-p") == 0) {
  		size_t count;
  		struct mrsh_collect_var *vars = mrsh_collect_vars(


@@ 26,7 26,7 @@ printf("\n");
  		}
  		free(vars);
- 		return EXIT_SUCCESS;
+ 		return 0;
  	}
  
  	for (int i = 1; i < argc; ++i) {


@@ 50,11 50,11 @@ fprintf(stderr, "%s: cannot modify readonly variable %s\n",
  					argv[0], key);
  			free(key);
- 			return EXIT_FAILURE;
+ 			return 1;
  		}
  		mrsh_env_set(state, key, val, attrib | prev_attribs);
  		free(key);
  	}
  
- 	return EXIT_SUCCESS;
+ 	return 0;
  }

M builtin/false.c => builtin/false.c +1 -1
@@ 3,5 3,5 @@ #include "builtin.h"
  
  int builtin_false(struct mrsh_state *state, int argc, char *argv[]) {
- 	return EXIT_FAILURE;
+ 	return 1;
  }

M builtin/getopts.c => builtin/getopts.c +6 -6
@@ 16,11 16,11 @@ if (mrsh_getopt(argc, argv, ":") != -1) {
  		fprintf(stderr, "getopts: unknown option -- %c\n", mrsh_optopt);
  		fprintf(stderr, getopts_usage);
- 		return EXIT_FAILURE;
+ 		return 1;
  	}
  	if (mrsh_optind + 2 < argc) {
  		fprintf(stderr, getopts_usage);
- 		return EXIT_FAILURE;
+ 		return 1;
  	}
  
  	int optc;


@@ 38,13 38,13 @@ const char *optind_str = mrsh_env_get(state, "OPTIND", NULL);
  	if (optind_str == NULL) {
  		fprintf(stderr, "getopts: OPTIND is not defined\n");
- 		return EXIT_FAILURE;
+ 		return 1;
  	}
  	char *endptr;
  	long optind_long = strtol(optind_str, &endptr, 10);
  	if (endptr[0] != '\0' || optind_long <= 0 || optind_long > INT_MAX) {
  		fprintf(stderr, "getopts: OPTIND is not a positive integer\n");
- 		return EXIT_FAILURE;
+ 		return 1;
  	}
  	mrsh_optind = (int)optind_long;
  


@@ 90,7 90,7 @@ mrsh_env_set(state, name, value, MRSH_VAR_ATTRIB_NONE);
  
  	if (opt == -1) {
- 		return EXIT_FAILURE;
+ 		return 1;
  	}
- 	return EXIT_SUCCESS;
+ 	return 0;
  }

M builtin/pwd.c => builtin/pwd.c +5 -5
@@ 16,23 16,23 @@ case 'P':
  			// TODO implement `-L` and `-P`
  			fprintf(stderr, "pwd: `-L` and `-P` not yet implemented\n");
- 			return EXIT_FAILURE;
+ 			return 1;
  		default:
  			fprintf(stderr, "pwd: unknown option -- %c\n", mrsh_optopt);
  			fprintf(stderr, pwd_usage);
- 			return EXIT_FAILURE;
+ 			return 1;
  		}
  	}
  	if (mrsh_optind < argc) {
  		fprintf(stderr, pwd_usage);
- 		return EXIT_FAILURE;
+ 		return 1;
  	}
  
  	const char *pwd = mrsh_env_get(state, "PWD", NULL);
  	if (pwd == NULL) {
  		fprintf(stderr, "pwd: Cannot return current directory as PWD was unset\n");
- 		return EXIT_FAILURE;
+ 		return 1;
  	}
  	puts(pwd);
- 	return EXIT_SUCCESS;
+ 	return 0;
  }

M builtin/read.c => builtin/read.c +3 -3
@@ 24,12 24,12 @@ default:
  			fprintf(stderr, "read: unknown option -- %c\n", mrsh_optopt);
  			fprintf(stderr, read_usage);
- 			return EXIT_FAILURE;
+ 			return 1;
  		}
  	}
  	if (mrsh_optind == argc) {
  		fprintf(stderr, read_usage);
- 		return EXIT_FAILURE;
+ 		return 1;
  	}
  
  	struct mrsh_buffer buf = {0};


@@ 89,5 89,5 @@ free(fields.data[i]);
  	}
  	mrsh_array_finish(&fields);
- 	return EXIT_SUCCESS;
+ 	return 0;
  }

M builtin/set.c => builtin/set.c +8 -8
@@ 95,7 95,7 @@ printf("\n");
  		}
  		free(vars);
- 		return EXIT_SUCCESS;
+ 		return 0;
  	}
  
  	bool force_positional = false;


@@ 111,19 111,19 @@ }
  		if (argv[i][1] == '\0') {
  			fprintf(stderr, set_usage);
- 			return EXIT_FAILURE;
+ 			return 1;
  		}
  		const struct option_map *option;
  		switch (argv[i][1]) {
  		case 'o':
  			if (i + 1 == argc) {
  				fprintf(stderr, set_usage);
- 				return EXIT_FAILURE;
+ 				return 1;
  			}
  			option = find_long_option(argv[i + 1]);
  			if (!option) {
  				fprintf(stderr, set_usage);
- 				return EXIT_FAILURE;
+ 				return 1;
  			}
  			if (argv[i][0] == '-') {
  				state->options |= option->value;


@@ 135,7 135,7 @@ case 'c':
  			if (init_args == NULL) {
  				fprintf(stderr, set_usage);
- 				return EXIT_FAILURE;
+ 				return 1;
  			}
  			state->interactive = false;
  			init_args->command_str = argv[i + 1];


@@ 144,7 144,7 @@ case 's':
  			if (init_args == NULL) {
  				fprintf(stderr, set_usage);
- 				return EXIT_FAILURE;
+ 				return 1;
  			}
  			init_args->command_str = NULL;
  			init_args->command_file = NULL;


@@ 154,7 154,7 @@ option = find_option(argv[i][j]);
  				if (!option) {
  					fprintf(stderr, set_usage);
- 					return EXIT_FAILURE;
+ 					return 1;
  				}
  				if (argv[i][0] == '-') {
  					state->options |= option->value;


@@ 187,7 187,7 @@ state->args->argv = argv_dup(strdup(argv[0]), 1, argv);
  	}
  
- 	return EXIT_SUCCESS;
+ 	return 0;
  }
  
  int builtin_set(struct mrsh_state *state, int argc, char *argv[]) {

M builtin/shift.c => builtin/shift.c +9 -9
@@ 9,7 9,7 @@ int builtin_shift(struct mrsh_state *state, int argc, char *argv[]) {
  	if (argc > 2) {
  		fprintf(stderr, shift_usage);
- 		return EXIT_FAILURE;
+ 		return 1;
  	}
  	int n = 1;
  	if (argc == 2) {


@@ 19,26 19,26 @@ if (*endptr != '\0' || errno != 0) {
  			fprintf(stderr, shift_usage);
  			if (!state->interactive) {
- 				state->exit = EXIT_FAILURE;
+ 				state->exit = 1;
  			}
- 			return EXIT_FAILURE;
+ 			return 1;
  		}
  		n = (int)n_long;
  	}
  	if (n == 0) {
- 		return EXIT_SUCCESS;
+ 		return 0;
  	} else if (n < 1) {
  		fprintf(stderr, "shift: [n] must be positive\n");
  		if (!state->interactive) {
- 			state->exit = EXIT_FAILURE;
+ 			state->exit = 1;
  		}
- 		return EXIT_FAILURE;
+ 		return 1;
  	} else if (n > state->args->argc - 1) {
  		fprintf(stderr, "shift: [n] must be less than $#\n");
  		if (!state->interactive) {
- 			state->exit = EXIT_FAILURE;
+ 			state->exit = 1;
  		}
- 		return EXIT_FAILURE;
+ 		return 1;
  	}
  	for (int i = 1, j = n + 1; j < state->args->argc; ++i, ++j) {
  		if (j <= state->args->argc - n) {


@@ 48,5 48,5 @@ }
  	}
  	state->args->argc -= n;
- 	return EXIT_SUCCESS;
+ 	return 0;
  }

M builtin/times.c => builtin/times.c +4 -4
@@ 12,19 12,19 @@ int builtin_times(struct mrsh_state *state, int argc, char *argv[]) {
  	if (argc > 1) {
  		fprintf(stderr, times_usage);
- 		return EXIT_FAILURE;
+ 		return 1;
  	}
  
  	struct tms buf;
  	long clk_tck = sysconf(_SC_CLK_TCK);
  	if (clk_tck == -1) {
  		fprintf(stderr, "sysconf error: %s", strerror(errno));
- 		return EXIT_FAILURE;
+ 		return 1;
  	}
  
  	if (times(&buf) == (clock_t)-1) {
  		fprintf(stderr, "times error: %s", strerror(errno));
- 		return EXIT_FAILURE;
+ 		return 1;
  	}
  
  	printf("%dm%fs %dm%fs\n%dm%fs %dm%fs\n",


@@ 37,5 37,5 @@ (int)(buf.tms_cstime / clk_tck / 60),
  			((double)buf.tms_cstime) / clk_tck);
  
- 	return EXIT_SUCCESS;
+ 	return 0;
  }

M builtin/true.c => builtin/true.c +1 -1
@@ 3,5 3,5 @@ #include "builtin.h"
  
  int builtin_true(struct mrsh_state *state, int argc, char *argv[]) {
- 	return EXIT_SUCCESS;
+ 	return 0;
  }

M builtin/type.c => builtin/type.c +3 -3
@@ 13,11 13,11 @@ if (mrsh_getopt(argc, argv, ":") != -1) {
  		fprintf(stderr, "type: unknown option -- %c\n", mrsh_optopt);
  		fprintf(stderr, type_usage);
- 		return EXIT_FAILURE;
+ 		return 1;
  	}
  	if (mrsh_optind == argc) {
  		fprintf(stderr, type_usage);
- 		return EXIT_FAILURE;
+ 		return 1;
  	}
  
  	bool error = false;


@@ 45,5 45,5 @@ error = true;
  	}
  
- 	return error ? EXIT_FAILURE : EXIT_SUCCESS;
+ 	return error ? 1 : 0;
  }

M builtin/ulimit.c => builtin/ulimit.c +7 -7
@@ 21,7 21,7 @@ // Nothing here
  		} else {
  			fprintf(stderr, "%s", ulimit_usage);
- 			return EXIT_FAILURE;
+ 			return 1;
  		}
  	}
  


@@ 32,12 32,12 @@ long int new_limit = strtol(arg, &endptr, 10);
  		if (errno != 0) {
  			fprintf(stderr, "strtol error: %s\n", strerror(errno));
- 			return EXIT_FAILURE;
+ 			return 1;
  		}
  		if ((endptr == arg) || (endptr[0] != '\0')) {
  			fprintf(stderr, "ulimit error: Invalid argument: %s\n",
  				arg);
- 			return EXIT_FAILURE;
+ 			return 1;
  		}
  		struct rlimit new = {
  			.rlim_cur = new_limit * 512,


@@ 45,13 45,13 @@ };
  		if (setrlimit(RLIMIT_FSIZE, &new) != 0) {
  			fprintf(stderr, "setrlimit error: %s\n", strerror(errno));
- 			return EXIT_FAILURE;
+ 			return 1;
  		}
  	} else if (mrsh_optind == argc) {
  		struct rlimit old = { 0 };
  		if (getrlimit(RLIMIT_FSIZE, &old) != 0) {
  			fprintf(stderr, "getrlimit error: %s\n", strerror(errno));
- 			return EXIT_FAILURE;
+ 			return 1;
  		}
  		if (old.rlim_max == RLIM_INFINITY) {
  			printf("unlimited\n");


@@ 60,8 60,8 @@ }
  	} else {
  		fprintf(stderr, "%s", ulimit_usage);
- 		return EXIT_FAILURE;
+ 		return 1;
  	}
  
- 	return EXIT_SUCCESS;
+ 	return 0;
  }

M builtin/umask.c => builtin/umask.c +4 -4
@@ 174,7 174,7 @@ default:
  			fprintf(stderr, "Unknown option -- '%c'\n", mrsh_optopt);
  			fprintf(stderr, umask_usage);
- 			return EXIT_FAILURE;
+ 			return 1;
  		}
  	}
  


@@ 187,7 187,7 @@ printf("%04o\n", mode);
  		}
  
- 		return EXIT_SUCCESS;
+ 		return 0;
  	}
  
  	char *endptr;


@@ 196,10 196,10 @@ if (*endptr != '\0') {
  		if (!umask_mode(&mode, argv[mrsh_optind])) {
  			fprintf(stderr, umask_usage);
- 			return EXIT_FAILURE;
+ 			return 1;
  		}
  	}
  
  	umask(mode);
- 	return EXIT_SUCCESS;
+ 	return 0;
  }

M builtin/unalias.c => builtin/unalias.c +5 -5
@@ 25,26 25,26 @@ default:
  			fprintf(stderr, "unalias: unknown option -- %c\n", mrsh_optopt);
  			fprintf(stderr, unalias_usage);
- 			return EXIT_FAILURE;
+ 			return 1;
  		}
  	}
  
  	if (all) {
  		if (mrsh_optind < argc) {
  			fprintf(stderr, unalias_usage);
- 			return EXIT_FAILURE;
+ 			return 1;
  		}
  		mrsh_hashtable_for_each(&state->aliases, delete_alias_iterator, &state->aliases);
- 		return EXIT_SUCCESS;
+ 		return 0;
  	}
  
  	if (mrsh_optind == argc) {
  		fprintf(stderr, unalias_usage);
- 		return EXIT_FAILURE;
+ 		return 1;
  	}
  
  	for (int i = mrsh_optind; i < argc; ++i) {
  		free(mrsh_hashtable_del(&state->aliases, argv[i]));
  	}
- 	return EXIT_SUCCESS;
+ 	return 0;
  }

M builtin/unset.c => builtin/unset.c +4 -4
@@ 24,12 24,12 @@ default:
  			fprintf(stderr, "unset: unknown option -- %c\n", mrsh_optopt);
  			fprintf(stderr, unset_usage);
- 			return EXIT_FAILURE;
+ 			return 1;
  		}
  	}
  	if (mrsh_optind >= argc) {
  		fprintf(stderr, unset_usage);
- 		return EXIT_FAILURE;
+ 		return 1;
  	}
  	for (int i = mrsh_optind; i < argc; ++i) {
  		if (!funcs) {


@@ 38,7 38,7 @@ if ((prev_attribs & MRSH_VAR_ATTRIB_READONLY)) {
  					fprintf(stderr,
  						"unset: cannot modify readonly variable %s\n", argv[i]);
- 					return EXIT_FAILURE;
+ 					return 1;
  				}
  				mrsh_env_unset(state, argv[i]);
  			}


@@ 48,5 48,5 @@ mrsh_function_destroy(oldfn);
  		}
  	}
- 	return EXIT_SUCCESS;
+ 	return 0;
  }

M builtin/unspecified.c => builtin/unspecified.c +2 -2
@@ 11,8 11,8 @@ } else {
  		fprintf(stderr, "%s: The behavior of this command is undefined. "
  				"This is an error in your script. Aborting.\n", argv[0]);
- 		state->exit = EXIT_FAILURE;
+ 		state->exit = 1;
  	}
  
- 	return EXIT_FAILURE;
+ 	return 1;
  }

M highlight.c => highlight.c +5 -5
@@ 45,7 45,7 @@ } else {
  		if (state->fmt_stack_len >= FORMAT_STACK_SIZE) {
  			fprintf(stderr, "format stack overflow\n");
- 			exit(EXIT_FAILURE);
+ 			exit(1);
  		}
  		state->fmt_stack[state->fmt_stack_len] = fmt;
  		++state->fmt_stack_len;


@@ 300,7 300,7 @@ ssize_t n_read = read(STDIN_FILENO, dst, READ_SIZE);
  		if (n_read < 0) {
  			fprintf(stderr, "read() failed: %s\n", strerror(errno));
- 			return EXIT_FAILURE;
+ 			return 1;
  		} else if (n_read == 0) {
  			break;
  		}


@@ 313,9 313,9 @@ const char *err_msg = mrsh_parser_error(parser, NULL);
  		if (err_msg != NULL) {
  			fprintf(stderr, "failed to parse script: %s\n", err_msg);
- 			return EXIT_FAILURE;
+ 			return 1;
  		}
- 		return EXIT_SUCCESS;
+ 		return 0;
  	}
  	mrsh_parser_destroy(parser);
  


@@ 333,5 333,5 @@ assert(state.fmt_stack_len == 0);
  
  	mrsh_buffer_finish(&buf);
- 	return EXIT_SUCCESS;
+ 	return 0;
  }

M main.c => main.c +6 -6
@@ 21,13 21,13 @@ mrsh_state_init(&state);
  
  	struct mrsh_init_args init_args = {0};
- 	if (mrsh_process_args(&state, &init_args, argc, argv) != EXIT_SUCCESS) {
+ 	if (mrsh_process_args(&state, &init_args, argc, argv) != 0) {
  		mrsh_state_finish(&state);
- 		return EXIT_FAILURE;
+ 		return 1;
  	}
  
  	if (!mrsh_populate_env(&state, environ)) {
- 		return EXIT_FAILURE;
+ 		return 1;
  	}
  
  	if (!(state.options & MRSH_OPT_NOEXEC)) {


@@ 56,7 56,7 @@ if (fd < 0) {
  					fprintf(stderr, "failed to open %s for reading: %s\n",
  						init_args.command_file, strerror(errno));
- 					return EXIT_FAILURE;
+ 					return 1;
  				}
  			} else {
  				fd = STDIN_FILENO;


@@ 107,7 107,7 @@ if (state.interactive) {
  					continue;
  				} else {
- 					state.exit = EXIT_FAILURE;
+ 					state.exit = 1;
  					break;
  				}
  			} else if (mrsh_parser_eof(parser)) {


@@ 115,7 115,7 @@ break;
  			} else {
  				fprintf(stderr, "unknown error\n");
- 				state.exit = EXIT_FAILURE;
+ 				state.exit = 1;
  				break;
  			}
  		} else {

M shell/redir.c => shell/redir.c +2 -2
@@ 82,11 82,11 @@ ssize_t n = write_here_document_line(fds[1], line, -1);
  			if (n < 0) {
  				close(fds[1]);
- 				exit(EXIT_FAILURE);
+ 				exit(1);
  			}
  		}
  		close(fds[1]);
- 		exit(EXIT_SUCCESS);
+ 		exit(0);
  	}
  
  	close(fds[1]);

M shell/shell.c => shell/shell.c +1 -1
@@ 84,7 84,7 @@ struct mrsh_variable *var = calloc(1, sizeof(struct mrsh_variable));
  	if (!var) {
  		fprintf(stderr, "Failed to allocate shell variable");
- 		exit(EXIT_FAILURE);
+ 		exit(1);
  	}
  	var->value = strdup(value);
  	var->attribs = attribs;

M shell/task/assignment.c => shell/task/assignment.c +2 -2
@@ 32,14 32,14 @@ free(new_value);
  			fprintf(stderr, "cannot modify readonly variable %s\n",
  					assign->name);
- 			task->status = EXIT_FAILURE;
+ 			task->status = 1;
  			return TASK_STATUS_ERROR;
  		}
  		mrsh_env_set(ctx->state, assign->name, new_value, attribs);
  		free(new_value);
  	}
  
- 	return EXIT_SUCCESS;
+ 	return 0;
  }
  
  static const struct task_interface task_assignment_impl = {

M shell/task/async.c => shell/task/async.c +2 -2
@@ 34,7 34,7 @@ } else if (child_pid == 0) {
  			return 0;
  		} else {
- 			exit(EXIT_SUCCESS);
+ 			exit(0);
  		}
  	} else {
  		if (waitpid(pid, NULL, 0) == -1) {


@@ 60,7 60,7 @@ if (fd < 0) {
  				fprintf(stderr, "failed to open /dev/null: %s\n",
  					strerror(errno));
- 				exit(EXIT_FAILURE);
+ 				exit(1);
  			}
  			dup2(fd, STDIN_FILENO);
  			close(fd);

M shell/task/command_process.c => shell/task/command_process.c +2 -2
@@ 51,7 51,7 @@ int redir_fd;
  			int fd = process_redir(redir, &redir_fd);
  			if (fd < 0) {
- 				exit(EXIT_FAILURE);
+ 				exit(1);
  			}
  
  			if (fd == redir_fd) {


@@ 62,7 62,7 @@ if (ret < 0) {
  				fprintf(stderr, "cannot duplicate file descriptor: %s\n",
  					strerror(errno));
- 				exit(EXIT_FAILURE);
+ 				exit(1);
  			}
  			close(fd);
  		}

M shell/task/task.c => shell/task/task.c +1 -1
@@ 37,7 37,7 @@ int ret = task_poll(task, ctx);
  		if (ret != TASK_STATUS_WAIT) {
  			ctx->state->last_status = ret;
- 			if (ret != EXIT_SUCCESS
+ 			if (ret != 0
  					&& (ctx->state->options & MRSH_OPT_ERREXIT)) {
  				ctx->state->exit = ret;
  			}

M shell/task/word.c => shell/task/word.c +2 -2
@@ 86,7 86,7 @@ mrsh_run_program(ctx->state, wc->program);
  		}
  
- 		exit(ctx->state->exit >= 0 ? ctx->state->exit : EXIT_SUCCESS);
+ 		exit(ctx->state->exit >= 0 ? ctx->state->exit : 0);
  	}
  
  	close(fds[1]);


@@ 227,7 227,7 @@ struct mrsh_word_string *ws =
  					mrsh_word_string_create(strdup(buf), false);
  				task_word_swap(tw, &ws->word);
- 				ret = EXIT_SUCCESS;
+ 				ret = 0;
  			}
  		}
  		mrsh_arithm_expr_destroy(expr);