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:
wescande 2017-03-24 14:49:46 +01:00
parent f0d98b1b2e
commit 1b9d0540da
5 changed files with 93 additions and 40 deletions

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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;
char **local_var;
t_list *lst_func;
char *binary;
};
t_data *data_singleton();

View file

@ -1,5 +1,9 @@
#!/bin/sh
verbose=0
if [ "$1" = "-v" ]
then
verbose=1
fi
word=$(git status -s | sed 's/.* //')
red="\033[38;5;1m"
gre="\033[38;5;2m"
@ -37,7 +41,6 @@ array_in_array ()
confirm ()
{
# call with a prompt string or use a default
echo "$cya${1:-Are you sure? [y/N]}$res"
read -r -p " " response
case "$response" in
@ -59,8 +62,10 @@ do_checkout ()
echo "$cya $i was checked out. A copy still exist in $HOME/Documents/.$i_tmp.back$res\n"
}
for i in $word
do
if [ $verbose -eq 1 ]
then
for i in $word
do
if [ -e $i ]
then
if [ -f $i ]
@ -98,4 +103,28 @@ do
else
echo "$red$i doesn't exist$res"
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

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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]);
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, command);
execve(data_singleton()->argv[0], av, data_singleton()->env);
execve(data_singleton()->binary, av, data_singleton()->env);
exit(1);
}
waitpid(pid, &ret, WUNTRACED);

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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;
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)
{
t_data *data;
@ -67,15 +89,16 @@ int data_init(int ac, char **av)
lexer_init(&data->lexer);
parser_init(&data->parser);
if ((term_name = ft_getenv(data->env, "TERM")) == NULL)
{
term_name = "dumb";
/* ft_dprintf(2, "{red}TERM not set\n{eoc}"); */
/* return (-1); */
}
if (tgetent(NULL, term_name) != 1)
{
ft_dprintf(2, "{red}TERM name is not a tty\n{eoc}");
return (-1);
}
if (path_binary_save(av[0]))
{
ft_dprintf(2, "{red}Failed to resolve binary name\n{eoc}");
return (-1);
}
return (0);
}

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 */
/* */
/* ************************************************************************** */