please use SH_ERR to display error messages
This commit is contained in:
parent
b688c4f544
commit
95e828b7b7
3 changed files with 9 additions and 6 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/10 13:07:44 by jhalford #+# #+# */
|
/* Created: 2016/11/10 13:07:44 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/21 02:11:31 by wescande ### ########.fr */
|
/* Updated: 2017/03/21 14:03:00 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -33,6 +33,9 @@
|
||||||
# include "hash.h"
|
# include "hash.h"
|
||||||
/* # define malloc(x) NULL */
|
/* # define malloc(x) NULL */
|
||||||
|
|
||||||
|
# define SH_MSG(s, ...) "{red}%s: " s "{eoc}\n", g_argv[0], ##__VA_ARGS__
|
||||||
|
# define SH_ERR(s, ...) ft_dprintf(STDERR, SH_MSG(s, ##__VA_ARGS__))
|
||||||
|
|
||||||
#ifndef DEBUG
|
#ifndef DEBUG
|
||||||
# define DEBUG_MODE 0
|
# define DEBUG_MODE 0
|
||||||
#else
|
#else
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/14 15:34:21 by jhalford #+# #+# */
|
/* Created: 2017/03/14 15:34:21 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/20 15:48:46 by jhalford ### ########.fr */
|
/* Updated: 2017/03/21 14:02:59 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
# define DG_ARGS getpid(), getpid(), ft_path_notdir(__FILE__), __LINE__
|
# define DG_ARGS getpid(), getpid(), ft_path_notdir(__FILE__), __LINE__
|
||||||
# define DG(s, ...) ft_dprintf(STDBUG,DG_MSG s "{eoc}\n",DG_ARGS,##__VA_ARGS__)
|
# define DG(s, ...) ft_dprintf(STDBUG,DG_MSG s "{eoc}\n",DG_ARGS,##__VA_ARGS__)
|
||||||
|
|
||||||
# define ERR_PROTO(s, ...) "{red}%s: " s "{eoc}\n", PROGNAME, ##__VA_ARGS__
|
# define ERR_MSG(s, ...) "{red}%s: " s "{eoc}\n", PROGNAME, ##__VA_ARGS__
|
||||||
# define ERR_SET(n, ...) error_set(n, ##__VA_ARGS__)
|
# define ERR_SET(n, ...) error_set(n, ##__VA_ARGS__)
|
||||||
# define ERRMSG_MAX_SIZE 150
|
# define ERRMSG_MAX_SIZE 150
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,13 +6,13 @@
|
||||||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/28 14:28:41 by jhalford #+# #+# */
|
/* Created: 2016/11/28 14:28:41 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/21 13:50:00 by jhalford ### ########.fr */
|
/* Updated: 2017/03/21 14:01:32 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "minishell.h"
|
#include "minishell.h"
|
||||||
|
|
||||||
#define EXITERR_0 SHELL_NAME ": numeric argument required\n"
|
#define EXITERR_0 "exit: numeric argument required"
|
||||||
|
|
||||||
int builtin_exit(const char *path, char *const av[], char *const envp[])
|
int builtin_exit(const char *path, char *const av[], char *const envp[])
|
||||||
{
|
{
|
||||||
|
|
@ -33,7 +33,7 @@ int builtin_exit(const char *path, char *const av[], char *const envp[])
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
if (av && av[1] && !ft_stris(av[1], ft_isdigit))
|
if (av && av[1] && !ft_stris(av[1], ft_isdigit))
|
||||||
error_msg(EXITERR_0);
|
SH_ERR(EXITERR_0);
|
||||||
status = (av && av[1]) ?
|
status = (av && av[1]) ?
|
||||||
ft_atoi(av[1]) : ft_atoi(ft_getenv(data_singleton()->env, "?"));
|
ft_atoi(av[1]) : ft_atoi(ft_getenv(data_singleton()->env, "?"));
|
||||||
if (SH_IS_INTERACTIVE(data_singleton()->opts))
|
if (SH_IS_INTERACTIVE(data_singleton()->opts))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue