test(builtin/export): ensure that identifiers are correctly accepted or rejected

This commit is contained in:
Khaïs COLIN 2025-04-18 10:19:57 +02:00
parent c5e15903e0
commit 5fabec58d5

25
test.sh
View file

@ -770,4 +770,29 @@ minishell: export: `0': not a valid identifier
1
EOF
when_run <<"EOF" "export with identifiers containing numbers"
export VAR1=this VAR2=should VAR3=work VAR4=no VAR5="problem!"
echo $VAR1 $VAR2 $VAR3 $VAR4 $VAR5
EOF
expecting <<EOF
this should work no problem!
EOF
when_run <<"EOF" "export with identifiers containing and starting with underscore"
export __var__=__value__ _snake_case_variable_names_=Pascal_Snake_Case
echo $__var__ $_snake_case_variable_names_
EOF
expecting <<EOF
__value__ Pascal_Snake_Case
EOF
when_run <<"EOF" "export with identifiers containing dashes"
export -VAR=value lisp-case="(defun botsbuildbots () (botsbuildbots))" --option-case=--no-preserve-root
EOF
expecting <<"EOF"
minishell: export: `-VAR=value': not a valid identifier
minishell: export: `lisp-case=(defun botsbuildbots () (botsbuildbots))': not a valid identifier
minishell: export: `--option-case=--no-preserve-root': not a valid identifier
EOF
finalize