Timeline for Setting an environment variable before a command in Bash is not working for the second command in a pipe
Current License: CC BY-SA 4.0
5 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Feb 7 at 14:57 | comment | added | Niels Bom |
Isn't the problem with unset that you may not want ENV to be unset? Maybe you want it to have the original value (before ENV=prod ).
|
|
Jan 18, 2022 at 17:04 | comment | added | Akhil |
adding ;unset ENV to the same line will make it one liner. but I ignored it as it doesn't make sense.
|
|
Aug 23, 2021 at 18:34 | comment | added | Derek Mahar |
It works because it defines ENV in the environment of the same shell in which the commands that follow the semicolon execute. How this differs from the other answers, though, is that this one defines ENV for all subsequent references in the shell and not just those on the same line. I believe that the original question intended to alter the environment only for the references on the same line.
|
|
Mar 19, 2021 at 9:57 | history | edited | Akhil | CC BY-SA 4.0 |
explained ;
|
Jun 20, 2020 at 7:50 | history | answered | Akhil | CC BY-SA 4.0 |