error message in cd builtin:
This commit is contained in:
parent
89fd444e84
commit
e34666665d
9 changed files with 26 additions and 27 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/07 13:33:27 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/20 16:13:24 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/21 15:20:08 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/20 15:52:57 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/20 15:53:17 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/21 15:19:56 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -28,13 +28,14 @@ t_conv g_convs[] =
|
|||
int ft_vdprintf(int fd, const char *format, va_list ap)
|
||||
{
|
||||
char *ret;
|
||||
char size;
|
||||
|
||||
ret = NULL;
|
||||
if (ft_vasprintf(&ret, format, ap))
|
||||
return (1);
|
||||
size = ft_vasprintf(&ret, format, ap);
|
||||
if (size != -1)
|
||||
ft_putstr_fd(ret, fd);
|
||||
ft_strdel(&ret);
|
||||
return (0);
|
||||
return (size);
|
||||
}
|
||||
|
||||
int ft_vasprintf(char **ret, const char *format, va_list ap)
|
||||
|
|
@ -53,14 +54,14 @@ int ft_vasprintf(char **ret, const char *format, va_list ap)
|
|||
else if (*str == '%')
|
||||
{
|
||||
if (ft_fmtcalc(&final, &str, ap))
|
||||
return (1);
|
||||
return (-1);
|
||||
}
|
||||
else
|
||||
final = ft_strjoin(final, (char[]){*str++, 0});
|
||||
ft_strdel(&tmp);
|
||||
}
|
||||
*ret = final;
|
||||
return (0);
|
||||
return (ft_strlen(final));
|
||||
}
|
||||
|
||||
int ft_fmtcalc(char **final, char **str, va_list ap)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/03 11:57:53 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/20 12:54:02 by wescande ### ########.fr */
|
||||
/* Updated: 2017/03/21 15:23:49 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -16,9 +16,9 @@
|
|||
#define CDOPT_P (1 << 1)
|
||||
#define HAS_CDOPT_P(x) (x & CD_OPT_P)
|
||||
#define HAS_CDOPT_L(x) (x & CD_OPT_L)
|
||||
#define CDERR_1 "{red}cd: no such file or directory: %s{eoc}\n"
|
||||
#define CDERR_2 "{red}cd: HOME not set{eoc}\n"
|
||||
#define CDERR_3 "{red}cd: too many arguments{eoc}\n"
|
||||
#define CDERR_1 "cd: no such file or directory: %s"
|
||||
#define CDERR_2 "cd: HOME not set"
|
||||
#define CDERR_3 "cd: too many arguments{eoc}"
|
||||
|
||||
static char *builtin_cd_special(char *const av[], char *const env[])
|
||||
{
|
||||
|
|
@ -28,13 +28,13 @@ static char *builtin_cd_special(char *const av[], char *const env[])
|
|||
{
|
||||
if (!(target = ft_getenv((char**)env, "HOME")))
|
||||
{
|
||||
ft_dprintf(2, CDERR_2);
|
||||
SH_ERR(CDERR_2);
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
else if (*av && *(av + 1))
|
||||
{
|
||||
ft_dprintf(2, CDERR_3);
|
||||
SH_ERR(CDERR_3);
|
||||
return (NULL);
|
||||
}
|
||||
else if (ft_strcmp(*av, "-") == 0)
|
||||
|
|
@ -87,7 +87,7 @@ int builtin_cd(const char *path,
|
|||
free(cwd);
|
||||
if (chdir(target))
|
||||
{
|
||||
ft_dprintf(2, CDERR_1, target);
|
||||
SH_ERR(CDERR_1, target);
|
||||
return (builtin_return_status(0, 1));
|
||||
}
|
||||
else if (target != av[i])
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/28 14:21:41 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/20 14:40:00 by wescande ### ########.fr */
|
||||
/* Updated: 2017/03/21 15:21:05 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/01/20 15:01:45 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/21 14:10:51 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/21 15:16:34 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -28,7 +28,7 @@ t_cliopts g_read_opts[] =
|
|||
|
||||
void bt_read_usage(void)
|
||||
{
|
||||
ft_dprintf(2, "usage: read %s %s\n", US_READ, US_READ_1);
|
||||
SH_ERR("usage: read %s %s\n", US_READ, US_READ_1);
|
||||
}
|
||||
|
||||
int bt_read_init(t_read *data, char **av)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/20 12:48:04 by wescande #+# #+# */
|
||||
/* Updated: 2017/03/20 12:49:18 by wescande ### ########.fr */
|
||||
/* Updated: 2017/03/21 15:21:09 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,13 +6,13 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/28 14:25:17 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/21 01:43:33 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/21 15:20:27 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
#define SETERR_0 "invalid variable name\n"
|
||||
#define SETERR_0 "setenv: invalid variable name"
|
||||
|
||||
static int assign_var(char *const av[], char ***env)
|
||||
{
|
||||
|
|
@ -59,7 +59,7 @@ int builtin_setenv(const char *path,
|
|||
ret = word_is_assignment((char *[]){av[1], (esc + 1)});
|
||||
ft_strdel(&esc);
|
||||
if (!ret && ft_strcmp(av[1], "?"))
|
||||
return (error_msg(SETERR_0));
|
||||
return (SH_ERR(SETERR_0));
|
||||
assign_var(av, env);
|
||||
}
|
||||
return (envp ? builtin_return_status(0, 0) : 0);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/20 23:21:37 by ariard #+# #+# */
|
||||
/* Updated: 2017/03/20 23:21:56 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/21 15:20:26 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -17,5 +17,3 @@ int error_msg(char *msg)
|
|||
ft_dprintf(2, "{red}%s{eoc}", msg);
|
||||
return (1);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/15 17:43:01 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/21 14:48:17 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/21 15:15:05 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue