Closed Thomas-Chqt closed 1 year ago
Should do :
bash-3.2$ test=123
bash-3.2$ echo $? "'$test'"
0 '123'
bash-3.2$ te.st=123
bash: te.st=123: command not found
bash-3.2$ echo $? "'$test'"
127 ''
bash-3.2$ test=123
bash-3.2$ echo $test
123
bash-3.2$ test=
bash-3.2$ echo $? "'$test'"
0 ''
bash-3.2$ te st=123
bash: te: command not found
bash-3.2$ echo $? "'$test' '$te' '$st'"
127 '' '' ''
bash-3.2$ test=123 ls -l
total 5560
-rw-r--r--@ 1 tchoquet 2020 2310 Aug 17 13:42 Makefile
-rw-r--r--@ 1 tchoquet 2020 1308756 Jul 27 17:41 Subject_en.pdf
-rw-r--r--@ 1 tchoquet 2020 1310885 Jul 24 11:45 Subject_fr.pdf
-rw-r--r-- 1 tchoquet 2020 59333 Aug 21 19:37 exec.drawio.svg
-rw-r--r--@ 1 tchoquet 2020 47328 Aug 6 16:10 grap.drawio.svg
drwxr-xr-x 12 tchoquet 2020 408 Aug 21 19:57 includes
-rwxr-xr-x 1 tchoquet 2020 101904 Aug 21 19:53 minishell_debug
-rw-r--r--@ 1 tchoquet 2020 1980 Aug 14 11:42 shell_grammar
drwxr-xr-x 42 tchoquet 2020 1428 Aug 21 19:57 sources
bash-3.2$ echo $? "'$test'"
0 ''
bash-3.2$ test=123 | ls -l
total 5560
-rw-r--r--@ 1 tchoquet 2020 2310 Aug 17 13:42 Makefile
-rw-r--r--@ 1 tchoquet 2020 1308756 Jul 27 17:41 Subject_en.pdf
-rw-r--r--@ 1 tchoquet 2020 1310885 Jul 24 11:45 Subject_fr.pdf
-rw-r--r-- 1 tchoquet 2020 59333 Aug 21 19:37 exec.drawio.svg
-rw-r--r--@ 1 tchoquet 2020 47328 Aug 6 16:10 grap.drawio.svg
drwxr-xr-x 12 tchoquet 2020 408 Aug 21 19:57 includes
-rwxr-xr-x 1 tchoquet 2020 101904 Aug 21 19:53 minishell_debug
-rw-r--r--@ 1 tchoquet 2020 1980 Aug 14 11:42 shell_grammar
drwxr-xr-x 42 tchoquet 2020 1428 Aug 21 19:57 sources
bash-3.2$ echo $? "'$test'"
0 ''
bash-3.2$ test=123 | qwerty
bash: qwerty: command not found
bash-3.2$ echo $? "'$test'"
127 ''
bash-3.2$ pwd test=123
/Users/tchoquet/Documents/42Projects/minishell/minishell
bash-3.2$ echo $? "'$test'"
0 ''
bash-3.2$ pwd | test=123
bash-3.2$ echo $? "'$test'"
0 ''
@jizots
in the case of a environment set before a regular command without pipe like test=123 ls -l
i can do it after the lexer by just removing one token but i case of using with a pipe like test=123 | ls -l
or pwd | test=123
you need to do it inside the execution by just checking if its a good identifier, if it is, just ignore it, if not, use it as a command (it will print command not found
)
OK. I will modify code.
exemple
test=132