Skip to content

bash is not a login shell #167

Closed
Closed

Description

@cgull

When bash.exe is run without arguments, it invokes /bin/bash with no flags; this results in an interactive, non-login shell. But this is generally understood to mean a subshell invoked in a session that has already had a login shell run (-bash or bash --login), which is how .profile or .bash_profile get invoked. So the environment and other aspects of the session may not be configured as expected.

In the WSL environment, a login shell might not be the right thing. But what's happening now isn't quite right either.

Activity

  1. benhillis commented on Apr 13, 2016

    @benhillis
    Member

    You bring up an Interesting point. I'll play around with what happens if we switch to launching bash with the --login argument. If you want to try this locally and see if things work better for you can run:
    bash.exe -c "/bin/bash --login"

  2. dreyks commented on Apr 13, 2016

    @dreyks
    root@localhost:/mnt/c/Users/dreyk# bash --login
    mesg: /dev/tty: Operation not permitted
    root@localhost:/mnt/c/Users/dreyk# logout
    root@localhost:/mnt/c/Users/dreyk#
    

    the new shell is starting though. not sure what's causing this

  3. benhillis commented on Apr 14, 2016

    @benhillis
    Member

    The operation not permitted issue on /dev/tty is something I fixed recently and should be one of the next flights.

    Internally I've been playing launching bash with this option and it seems to me that there aren't any downsides launching bash with this option.

  4. benhillis commented on Apr 19, 2016

    @benhillis
    Member

    cgull - regarding launching bash as a login shell, we pass command line parameters to /bin/bash so if you use "bash.exe --login", /bin/bash will be launched with the same arg. Going to go ahead and close out this thread but feel free to follow up if this workaround doesn't work for you.

  5. simonbuchan commented on May 12, 2016

    @simonbuchan

    Ben Hillis (@benhillis) , when invoked (eg from a shortcut) as bash --login, it doesn't seem possible to make the initial directory ~? It uses the windows current directory, or /mnt/c/Windows/System32, which of course can't be a VolFs path.
    Not sure if that counts as this bug, but it is a bit uglier to use bash -c "cd ~ && bash --login".

  6. benhillis commented on May 13, 2016

    @benhillis
    Member

    Simon Buchan (@simonbuchan) Thanks for bringing this up again. I took a look at bash.exe's command line parsing and we actually have a bug there that only allows '' to be used if it's the only command line argument. I have a fix that will strip the '' from the command line and pass remainder to /bin/bash.

    This will allow you to do the following types of things:

    1. Launch bash as a login shell in the user's home directory (bash.exe ~ --login)
    2. Pass an initial command to /bin/bash to execute in the user's home directory (bash.exe ~ -c "ls").
    3. If the ~ is not the first character it will be passed to /bin/bash. (bash.exe -c "ls ~")

    I'll be checking this change into our dev branch soon so you'll have to wait a while for the fix, but hopefully that will make the '~' argument more useful.

  7. kdbanman commented on Apr 1, 2017

    @kdbanman

    In case the above formatting confuses anyone else, I think this is what was intended:

    ...
    we actually have a bug there that only allows ~ to be used if it's the only command line argument. I have a fix that will strip the ~ from the command line and pass remainder to /bin/bash.
    ...

  8. muru commented on Jun 7, 2017

    @muru

    This can probably be marked as fixed in insider builds (same as #816) now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions