Merge branch 'master' of github.com:jzck/42sh

This commit is contained in:
wescande 2017-03-24 14:49:53 +01:00
commit cbb5059182
5 changed files with 55 additions and 16 deletions

View file

@ -26,9 +26,9 @@ Optional feature highly appreciated:
- Job Control and builtins `job`, `fg`, `bg` and operand `&`.
- Shell Scripting.
## shell / subshell
## Shell / Subshell
## line editing
## Line editing
Keys|Functions|
:-:|:--
@ -39,7 +39,7 @@ Keys|Functions|
<kbd>Ctrl</kbd>+<kbd>C</kbd>|Terminate/Kill current foreground process.
<kbd>Ctrl</kbd>+<kbd>Z</kbd>|Suspend/Stop current foreground process.
## history
## History
Keys|Functions|
:-:|:--
@ -51,8 +51,43 @@ Keys|Functions|
`!name`|Search for a command beginning with `name`.
`!?name`|Search for a command which contain `name`.
## autocompletion
## globbing
## hash table
## job control
## Autocompletion
Autocompletion works with binary, path and env variable.
Output is colored upon type.
Using arrows to navigate is supported.
Autorefreshing with a new input from the user: modification of the list of possibility.
Commands|Functions|
:-:|:--
`$> l[tab]`|Search for binary.
`$> ls s[tab]`|Search for path/files.
`$> $[tab]`|Search for variables in `env`.
## Globbing
Pattern|Behavior|
:-:|:--
`*`|Everything.
`**`|Match directory and sub-directory.
`?`|Single char.
`[a-z]`|Match range from `a` to `z`.
`[!a-z]` `[^a-z]`|Exclude range from `a` to `z`.
`{ab, ac}`|Match `ab` or `ac`.
## Hash table
Commands|Functions|
:-:|:--
`hash`|List the content of the hash table.
`hash -r`|Clear the memory of the hash table.
## Job Control
Commands|Functions|
:-:|:--
`jobs`|List all the current running jobs.
`fg`|Bring the most recent process to foreground.
`fg n`|Bring the specified jobs to foreground where `n` is the numerical value of the process found in `jobs`.
## scripting

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/08 14:31:42 by jhalford #+# #+# */
/* Updated: 2017/03/22 18:26:03 by jhalford ### ########.fr */
/* Updated: 2017/03/24 14:06:48 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -16,7 +16,7 @@ int exec_reset_job(t_job *job)
{
job->id = 0;
job->pgid = 0;
job->attrs = JOB_NOTIFIED;
job->attrs = 0;
job->first_process = NULL;
return (0);
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/15 17:43:01 by jhalford #+# #+# */
/* Updated: 2017/03/24 12:35:04 by wescande ### ########.fr */
/* Updated: 2017/03/24 14:08:12 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -66,13 +66,13 @@ int builtin_jobs(const char *path, char *const av[], char *const envp[])
(void)path;
(void)envp;
ft_bzero(&data, sizeof(t_data_template));
do_job_notification();
if (!SH_HAS_JOBC(data_singleton()->opts))
{
SH_ERR("jobs: %s", SH_MSG_NOJOBC);
return (1);
}
ft_bzero(&data, sizeof(t_data_template));
if (cliopts_get((char**)av, g_jobs_opts, &data))
return (ft_perror());
if (!*data.av_data)

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/09 20:39:06 by jhalford #+# #+# */
/* Updated: 2017/03/20 15:00:58 by jhalford ### ########.fr */
/* Updated: 2017/03/24 14:20:30 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -21,7 +21,8 @@ t_lexstate get_state_global(t_lexer *lexer)
c = lexer->str[lexer->pos];
cn = lexer->str[lexer->pos + 1];
cl = lexer->str[lexer->pos ? lexer->pos - 1 : 0];
cl = lexer->pos ? lexer->str[lexer->pos - 1] : 0;
DG("%i : '%c'", lexer->pos, cl);
ret = 0;
if ((ft_is_delim(c) && (ret = DELIM))
|| ((c == '&' || c == ';' || c == '|' || c == '!') && (ret = SEP))
@ -31,7 +32,8 @@ t_lexstate get_state_global(t_lexer *lexer)
|| ((c == '\"') && (ret = DQUOTE))
|| ((c == '`') && (ret = BQUOTE))
|| ((c == '(' || c == ')') && (ret = PAREN))
|| (((c == '{' && cn == ' ') || (c == '}' && cl == ' '))
|| (((c == '{' && (cn == ' ' || cn == 0))
|| (c == '}' && (cl == ' ' || cl == 0)))
&& (ret = CURLY_BRACKETS))
|| ((c == 0) && (ret = END)))
{

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/02 15:17:28 by gwojda #+# #+# */
/* Updated: 2017/03/18 15:13:46 by gwojda ### ########.fr */
/* Updated: 2017/03/24 14:05:58 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -26,6 +26,8 @@ int ft_buff_f6(char **str, size_t *pos)
int ft_control_d(char **str, size_t *pos)
{
if (!data_singleton()->line.is_prompt)
return (0);
if (!*str || (*str)[0] == '\0')
{
ft_putstr("exit\n");