mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-05 23:18:08 +01:00
cd: handle empty argument
This commit is contained in:
parent
8f3c15f096
commit
f1b2e1e22d
2 changed files with 21 additions and 2 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/03/31 16:20:17 by khais #+# #+# */
|
||||
/* Updated: 2025/03/31 16:56:16 by khais ### ########.fr */
|
||||
/* Updated: 2025/03/31 17:05:21 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -18,7 +18,9 @@
|
|||
|
||||
static void ft_chdir(char *path, t_minishell *app)
|
||||
{
|
||||
if (chdir(path) == 0)
|
||||
if (path[0] == '\0')
|
||||
app->last_return_value = 0;
|
||||
else if (chdir(path) == 0)
|
||||
app->last_return_value = 0;
|
||||
else
|
||||
{
|
||||
|
|
|
|||
17
test.sh
17
test.sh
|
|
@ -210,6 +210,23 @@ minishell: cd: HOME not set
|
|||
/tmp/dir.minishell
|
||||
EOF
|
||||
|
||||
when_run <<EOF "cd with empty argument"
|
||||
cd ""
|
||||
pwd
|
||||
EOF
|
||||
expecting <<EOF
|
||||
/tmp/dir.minishell
|
||||
EOF
|
||||
|
||||
EXTRAENV="HOME="
|
||||
when_run <<EOF "cd with no arguments and HOME equal to empty string"
|
||||
cd
|
||||
pwd
|
||||
EOF
|
||||
expecting <<EOF
|
||||
/tmp/dir.minishell
|
||||
EOF
|
||||
|
||||
when_run <<EOF "quoted parentheses are not operators"
|
||||
echo unclosed '('
|
||||
EOF
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue