-2

This question already has an answer here:

I read multiple articles refering the login shell and non-login shell,
still, I am very confused.
Difference between Login Shell and Non-Login Shell? - Unix & Linux Stack Exchange
The UNIX School: Login shell or a non-login shell?

Put it simple,
the shell I start from my own computer after I power on it,
Isn't it a login shell or non-login shell?

    $ echo $SHELL
    /bin/bash
    $ echo $0
    -bash

Additionally, Could you please help to determine taht the shell called from a program is login shell or not?

    import subprocess
    subprocess.run('ls -l', shell=True)

marked as duplicate by jasonwryan, muru, G-Man, Christopher, jimmij Apr 2 '18 at 16:52

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    From one of the answers to the above: "# "-" is the first character. Therefore, this is a login shell.", and as for the program, that depends on on the program, doesn't it? – muru Apr 2 '18 at 3:32
1

As noted in this answer:

prompt> echo $0
-bash # "-" is the first character. Therefore, this is a login shell.

So your first example shows a login shell.

As also noted in the same answer,

Information can be found in man bash (search for Invocation). Here is an excerpt:

A login shell is one whose first character of argument zero is a -, or one started with the --login option.

And from the Python docs:

... Popen does the equivalent of:

Popen(['/bin/sh', '-c', args[0], args[1], ...])

Since the only option given is -c, it's not a login shell.

Not the answer you're looking for? Browse other questions tagged or ask your own question.