builtins: cd: implement cd to absolute paths

This commit is contained in:
Khaïs COLIN 2025-03-31 16:33:46 +02:00
parent 5ce4a2b85f
commit e93e6efb93
Signed by: logistic-bot
SSH key fingerprint: SHA256:RlpiqKeXpcPFZZ4y9Ou4xi2M8OhRJovIwDlbCaMsuAo
6 changed files with 69 additions and 8 deletions

22
test.sh
View file

@ -160,22 +160,34 @@ expecting <<EOF
/tmp/dir.minishell
EOF
when_run <<EOF "pwd works in any directory"
when_run <<EOF "pwd works in any directory, can cd to absolute paths"
mkdir test
cd test
cd /tmp/dir.minishell/test
pwd
mkdir hi
cd hi
cd /tmp/dir.minishell/test/hi
pwd
cd ..
cd /tmp/dir.minishell/test
pwd
EOF
todo <<EOF
expecting <<EOF
/tmp/dir.minishell/test
/tmp/dir.minishell/test/hi
/tmp/dir.minishell/test
EOF
when_run <<EOF "cd will print error when going into a directory with no access"
mkdir test
chmod -x test
cd test
pwd
chmod +x test
EOF
expecting <<EOF
minishell: cd: Permission denied
/tmp/dir.minishell
EOF
when_run <<EOF "quoted parentheses are not operators"
echo unclosed '('
EOF