Alicia-bites / minishell

This project is about creating a simple shell.
1 stars 0 forks source link

Isolated relative paths aren't properly interpreted #43

Closed ggmolly closed 2 years ago

ggmolly commented 2 years ago

MINISHELL:

$: .
Error: Permission denied: /usr/local/cuda-11.0/targets/x86_64-linux/lib/.
$: ..
Error: Permission denied: /usr/local/cuda-11.0/targets/x86_64-linux/lib/..
$: ../
Error: Permission denied: /usr/local/cuda-11.0/targets/x86_64-linux/lib/../

$: echo $PATH
/usr/local/cuda-11.0/targets/x86_64-linux/lib:/usr/local/cuda-11.0:/home/bacon/.cargo/bin:/home/bacon/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/home/bacon/.local/share/JetBrains/Toolbox/scripts

A single dot . is interpreted as a command, and not a path, which cause minishell to search a binary file called . on first directory in path

The sample above reveals a Permission denied error on an invalid relative path /usr/local/cuda-11.0/targets/x86_64-linux/lib/.

Expected behavior

The shell should understand that any relative path (., ../, etc) should be interpreted as paths and not as commands

Bash behavior example

bacon@omelet:~/goinfre/minishell$ .
bash: .: filename argument required
.: usage: . filename [arguments]
bacon@omelet:~/goinfre/minishell$ ..
..: command not found
bacon@omelet:~/goinfre/minishell$ ../
bash: ../: Is a directory