rectif bquote quand on change de dossier + ajout option -v pour le script + je sais plus trop quoi mais cest good
This commit is contained in:
parent
f0d98b1b2e
commit
1b9d0540da
5 changed files with 93 additions and 40 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/22 17:29:53 by ariard ### ########.fr */
|
/* Updated: 2017/03/24 13:35:44 by wescande ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -53,6 +53,7 @@ struct s_data
|
||||||
t_jobc jobc;
|
t_jobc jobc;
|
||||||
char **local_var;
|
char **local_var;
|
||||||
t_list *lst_func;
|
t_list *lst_func;
|
||||||
|
char *binary;
|
||||||
};
|
};
|
||||||
|
|
||||||
t_data *data_singleton();
|
t_data *data_singleton();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,9 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
verbose=0
|
||||||
|
if [ "$1" = "-v" ]
|
||||||
|
then
|
||||||
|
verbose=1
|
||||||
|
fi
|
||||||
word=$(git status -s | sed 's/.* //')
|
word=$(git status -s | sed 's/.* //')
|
||||||
red="\033[38;5;1m"
|
red="\033[38;5;1m"
|
||||||
gre="\033[38;5;2m"
|
gre="\033[38;5;2m"
|
||||||
|
|
@ -37,7 +41,6 @@ array_in_array ()
|
||||||
|
|
||||||
confirm ()
|
confirm ()
|
||||||
{
|
{
|
||||||
# call with a prompt string or use a default
|
|
||||||
echo "$cya${1:-Are you sure? [y/N]}$res"
|
echo "$cya${1:-Are you sure? [y/N]}$res"
|
||||||
read -r -p " " response
|
read -r -p " " response
|
||||||
case "$response" in
|
case "$response" in
|
||||||
|
|
@ -59,6 +62,8 @@ do_checkout ()
|
||||||
echo "$cya $i was checked out. A copy still exist in $HOME/Documents/.$i_tmp.back$res\n"
|
echo "$cya $i was checked out. A copy still exist in $HOME/Documents/.$i_tmp.back$res\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if [ $verbose -eq 1 ]
|
||||||
|
then
|
||||||
for i in $word
|
for i in $word
|
||||||
do
|
do
|
||||||
if [ -e $i ]
|
if [ -e $i ]
|
||||||
|
|
@ -99,3 +104,27 @@ do
|
||||||
echo "$red$i doesn't exist$res"
|
echo "$red$i doesn't exist$res"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
else
|
||||||
|
for i in $word
|
||||||
|
do
|
||||||
|
if [ -e $i ]
|
||||||
|
then
|
||||||
|
if [ -f $i ]
|
||||||
|
then
|
||||||
|
diff=$(git diff -U0 --exit-code --color $i)
|
||||||
|
if [ "$?" -eq 1 ]
|
||||||
|
then
|
||||||
|
nb_lines=$(echo "$diff" | wc -l)
|
||||||
|
if [ "$nb_lines" -eq 7 ]
|
||||||
|
then
|
||||||
|
match=$(array_in_array "-9 +9 Updated: by ### ########.fr" "$diff")
|
||||||
|
if [ $match -eq 1 ]
|
||||||
|
then
|
||||||
|
do_checkout
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/14 19:44:25 by wescande #+# #+# */
|
/* Created: 2017/03/14 19:44:25 by wescande #+# #+# */
|
||||||
/* Updated: 2017/03/23 03:19:23 by wescande ### ########.fr */
|
/* Updated: 2017/03/24 14:47:25 by wescande ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -44,10 +44,10 @@ char *command_getoutput(char *command)
|
||||||
{
|
{
|
||||||
close(fds[PIPE_READ]);
|
close(fds[PIPE_READ]);
|
||||||
dup2_close(fds[PIPE_WRITE], STDOUT);
|
dup2_close(fds[PIPE_WRITE], STDOUT);
|
||||||
av = ft_sstradd(NULL, data_singleton()->argv[0]);
|
av = ft_sstradd(NULL, data_singleton()->binary);
|
||||||
av = ft_sstradd(av, "-c");
|
av = ft_sstradd(av, "-c");
|
||||||
av = ft_sstradd(av, command);
|
av = ft_sstradd(av, command);
|
||||||
execve(data_singleton()->argv[0], av, data_singleton()->env);
|
execve(data_singleton()->binary, av, data_singleton()->env);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
waitpid(pid, &ret, WUNTRACED);
|
waitpid(pid, &ret, WUNTRACED);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/28 19:26:32 by jhalford #+# #+# */
|
/* Created: 2016/11/28 19:26:32 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/23 14:57:19 by ariard ### ########.fr */
|
/* Updated: 2017/03/24 13:51:24 by wescande ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -14,6 +14,28 @@
|
||||||
|
|
||||||
extern char **environ;
|
extern char **environ;
|
||||||
|
|
||||||
|
static int path_binary_save(char *binary)
|
||||||
|
{
|
||||||
|
char *directory;
|
||||||
|
|
||||||
|
if (binary[0] != '/')
|
||||||
|
{
|
||||||
|
if (!(directory = getcwd(NULL, 0)))
|
||||||
|
return (1);
|
||||||
|
while (binary[0] == '.' && binary[1] == '/')
|
||||||
|
binary += 2;
|
||||||
|
binary = ft_strjoin(
|
||||||
|
directory[ft_strlen(directory) - 1] != '/' ? "/" : "", binary);
|
||||||
|
binary = ft_strjoinf(directory, binary, 3);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
binary = ft_strdup(binary);
|
||||||
|
if (access(binary, F_OK | X_OK))
|
||||||
|
return (1);
|
||||||
|
data_singleton()->binary = binary;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
static int localenv_init(void)
|
static int localenv_init(void)
|
||||||
{
|
{
|
||||||
t_data *data;
|
t_data *data;
|
||||||
|
|
@ -67,15 +89,16 @@ int data_init(int ac, char **av)
|
||||||
lexer_init(&data->lexer);
|
lexer_init(&data->lexer);
|
||||||
parser_init(&data->parser);
|
parser_init(&data->parser);
|
||||||
if ((term_name = ft_getenv(data->env, "TERM")) == NULL)
|
if ((term_name = ft_getenv(data->env, "TERM")) == NULL)
|
||||||
{
|
|
||||||
term_name = "dumb";
|
term_name = "dumb";
|
||||||
/* ft_dprintf(2, "{red}TERM not set\n{eoc}"); */
|
|
||||||
/* return (-1); */
|
|
||||||
}
|
|
||||||
if (tgetent(NULL, term_name) != 1)
|
if (tgetent(NULL, term_name) != 1)
|
||||||
{
|
{
|
||||||
ft_dprintf(2, "{red}TERM name is not a tty\n{eoc}");
|
ft_dprintf(2, "{red}TERM name is not a tty\n{eoc}");
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
if (path_binary_save(av[0]))
|
||||||
|
{
|
||||||
|
ft_dprintf(2, "{red}Failed to resolve binary name\n{eoc}");
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/20 14:45:40 by gwojda #+# #+# */
|
/* Created: 2017/03/20 14:45:40 by gwojda #+# #+# */
|
||||||
/* Updated: 2017/03/23 16:58:43 by ariard ### ########.fr */
|
/* Updated: 2017/03/24 14:47:30 by wescande ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue