You are not logged in.
Hello all,
I can identify if I am in an interactive shell by checking for an occurance of 'i' in the variable '$-'.
I already know how to invoke an interactive login shell (bash --login for instance).
Let's say that I use a shell and I do not know how it was invoked ...
The question is how can I identify if I am in a login shell ?
Thank you for your help
Cheers,
Chicha
Offline
Quite easy... Any login shell will ask you for a username and password. Otherwise, it wouldn't be a login shell...
Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy
Offline
Thank you B for your help
But the exact question is :
Let's say that I use a shell and I do not know how it was invoked ...
Anyway I found a workaround :
echo $0
This will display 'bash' (or zsh, csh ...) in an interactive non-login shell and '-bash' (or -zsh ...) in an interactive login shell (notice the minus in front of the shell name).
I do not know if there is another way to find this information...
Cheers
Chicha
Offline
This is taken from the zsh user guide. I guess it's not the most practical solution, but it works.
if [[ -o login ]]; then
print yes
else
print no
fi
Offline
Thank you Borosai
This work very well for zsh and is exactly what I am looking for.
Any idea about how to do this with bash (the login option does not exist) ?
Offline
I have no idea about bash...sorry.
Offline
No problem
You gave me a good trick anyway !
Cheers,
Charles-Henri
Offline