JoeFootball wrote: ⤴
Thu May 24, 2018 1:09 pm
Perhaps you're looking to use the
variable? More information here
The problem is not that I used the
variable incorrectly. As you can see in the output of
, I used it right:
The problem is that if I ran that line with another shell like
it would not work because
is not supported by
rene wrote: ⤴
Thu May 24, 2018 4:37 pm
Kyowash wrote: ⤴
Thu May 24, 2018 1:05 pm
And this surprised me because
is mentioned here
I only see it mentioned in in section 8.1? There it's introduced by
It is unwise to conflict with certain variables that are frequently exported by widely used command interpreters and applications:
which is seemingly to say that indeed it's not standardised; the standard warns that you might want to avoid using a so named variable given that it's "frequently exported by widely used command interpreters". The following sections 8.2 and 8.3 -- and assumedly more sections scattered around the specifications -- list actually by the standard itself defined/mandated variables.
Yeah, that line misled me so that I thought that list was formed by standard environment variables. My bad!
So the variables supported by POSIX are just those found in section 8.2 and 8.3? That's a quite reduced list compared to the one I thought that was the correct one. Not even
is found there. And I'm again surprised because I made another script called
with this content:
Code: Select all
if [ "$USER" = "root" ]
echo "User is root."
shellcheck -s sh check-root-posix.sh
didn't complaint about it. I'm so confused right now.