env: implement builtin env

This commit is contained in:
Khaïs COLIN 2025-04-02 19:45:18 +02:00
parent 0de583cf45
commit 1ef8b7a0ae
Signed by: logistic-bot
SSH key fingerprint: SHA256:RlpiqKeXpcPFZZ4y9Ou4xi2M8OhRJovIwDlbCaMsuAo
6 changed files with 72 additions and 5 deletions

33
test.sh
View file

@ -305,6 +305,7 @@ EOF
EXTRAENV=-i
when_run <<EOF "export with strange inputs"
export ENV=$(which env)
export PATH=$PATH
export var
echo status=\$?
@ -312,7 +313,7 @@ echo var=[\$var]
export blue=
echo status=\$?
echo blue=[\$blue]
env -u PATH env
\$ENV -u PATH -u ENV env
EOF
expecting <<EOF
status=0
@ -451,6 +452,36 @@ hi -n hello
goodbye
EOF
EXTRAENV="-i"
when_run <<EOF "env works"
echo this should be empty:
env
echo
export var=VALUE hi=hello bye=goodbye
echo this contains some values
env
EOF
expecting <<EOF
this should be empty:
this contains some values
var=VALUE
hi=hello
bye=goodbye
EOF
EXTRAENV="-i"
when_run <<EOF "env ignores additional arguments"
export var=VALUE hi=hello bye=goodbye
env -i name="The Other" ls
EOF
expecting <<EOF
minishell: env: ignoring arguments
var=VALUE
hi=hello
bye=goodbye
EOF
when_run <<EOF "quoted parentheses are not operators"
echo unclosed '('
EOF