mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
fix: ';' is not a metacharacter
Co-authored-by: jguelen <jguelen@student.42lehavre.fr>
This commit is contained in:
parent
e877b8dbd5
commit
6e1552a35d
2 changed files with 16 additions and 9 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: kcolin <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/06 15:23:31 by kcolin #+# #+# */
|
||||
/* Updated: 2025/02/06 15:47:42 by kcolin ### ########.fr */
|
||||
/* Updated: 2025/02/11 19:04:03 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -16,14 +16,13 @@
|
|||
/*
|
||||
** return true if the character is a metacharacter
|
||||
**
|
||||
** Bash reference manual:
|
||||
** A character that, when unquoted, separates words. A metacharacter is a space,
|
||||
** tab, newline, or one of the following characters: ‘|’, ‘&’, ‘;’, ‘(’, ‘)’,
|
||||
** ‘<’, or ‘>’.
|
||||
** Bash reference manual: A character that, when unquoted, separates words. A
|
||||
** metacharacter is a space, tab, newline, or one of the following characters:
|
||||
** ‘|’, ‘&’, ‘(’, ‘)’, ‘<’, or ‘>’.
|
||||
*/
|
||||
bool is_metacharacter(char c)
|
||||
{
|
||||
if (c == ' ' || c == '\t' || c == '\n' || c == '|' || c == '&' || c == ';'
|
||||
if (c == ' ' || c == '\t' || c == '\n' || c == '|' || c == '&'
|
||||
|| c == '(' || c == ')' || c == '<' || c == '>')
|
||||
return (true);
|
||||
return (false);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: kcolin <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/06 15:21:00 by kcolin #+# #+# */
|
||||
/* Updated: 2025/02/06 15:57:40 by kcolin ### ########.fr */
|
||||
/* Updated: 2025/02/11 18:32:01 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -40,12 +40,20 @@ void test_metacharacters(void)
|
|||
assert(!is_metacharacter(c));
|
||||
c++;
|
||||
}
|
||||
char *metachars = " \t\n|&;()<>";
|
||||
char *not_metachars = ";[]{}*+=_-";
|
||||
int i = 0;
|
||||
while (not_metachars[i] != '\0')
|
||||
{
|
||||
dprintf(STDERR_FILENO, "%c", not_metachars[i]);
|
||||
assert(!is_metacharacter(not_metachars[i]));
|
||||
i++;
|
||||
}
|
||||
char *metachars = " \t\n|&()<>";
|
||||
i = 0;
|
||||
printf("\nmetachar:");
|
||||
while (metachars[i] != '\0')
|
||||
{
|
||||
printf("%c", metachars[i]);
|
||||
dprintf(STDERR_FILENO, "%c (%d) ", metachars[i], metachars[i]);
|
||||
assert(is_metacharacter(metachars[i]));
|
||||
i++;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue