Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shortcuts not starting bash as login shell #37

Closed
binkley opened this issue Apr 14, 2017 · 10 comments
Closed

Shortcuts not starting bash as login shell #37

binkley opened this issue Apr 14, 2017 · 10 comments

Comments

@binkley
Copy link

binkley commented Apr 14, 2017

I was trying to see bash was not sourcing the user profile files (~/.profile or ~/.bash_profile). Some poking around:

$ echo $-
himBHs
$ echo $0
/bin/bash

Contrasting with Cygwin (just an example, same result on other unix-y OSes):

$ echo $-
himBHs
$ echo $0
-bash

Unix shells treat a leading dash in argv0 as a signal to be a login shell, and source user profile files.

  • Is there a way in the wslbridge command line I can provide an explicit argv0 when running /bin/bash?
  • It might make sense for such an argv0 flag to be default in the shortcuts
@mintty
Copy link
Owner

mintty commented Apr 17, 2017

Check the three desktop shortcut options provided by the wsltty package, quoting from project page:

WSL Bash % in Mintty to start a WSL bash in the Windows %USERPROFILE% home
WSL Bash ~ in Mintty to start a WSL bash in the WSL user home
WSL Bash -l in Mintty to start a WSL login bash

The latter starts a login shell by invoking /bin/bash -l.

@mintty
Copy link
Owner

mintty commented Apr 20, 2017

Assuming things are clarified; closing.

@mintty mintty closed this as completed Apr 20, 2017
@binkley
Copy link
Author

binkley commented Apr 22, 2017

OK, thanks! I'm still making some edits to the shortcut, but I'm getting what I need. :)

Some observations:

  • The "WSL Bash -l" shortcut isn't appearing on my desktop, though the other two are
  • The "WSL Bash -l" shortcut does not use -C~ argument, so it's like the "%" one

I'd still prefer, if possible, to set argv0 to -bash for compatibility with Linux on login, but I can work around that. Thanks, again.

@mintty
Copy link
Owner

mintty commented Apr 23, 2017

The "WSL Bash -l" shortcut does not use -C~ argument, so it's like the "%" one

No, it uses the -l parameter, so it's not like %.

The standard Bash on Ubuntu shortcut does not start a login shell either, so the "hiding" (in the Start menu) of the WSL -l shortcut is kind of consistent.
The WSL invocation wrapper C:\Windows\System32\bash.exe can be started with an -l option, with the effect that your login .profile is activated. But $0 will still be /bin/bash then. This is an issue of that wrapper.

@athrunsun
Copy link

@mintty @binkley I'm sorry but I still don't quite understand.

Here is what is in my %LOCALAPPDATA%\wsltty\WSL~.bat:

@echo off
rem Start mintty terminal for WSL package  in current directory
%LOCALAPPDATA%\wsltty\bin\mintty.exe -i "%LOCALAPPDATA%/wsltty/wsl.ico" --WSL= -h err --configdir="%APPDATA%\wsltty" -~  

What changes should I make to obtain a login shell for wsltty?

@mintty
Copy link
Owner

mintty commented Nov 4, 2017

You can add an explicit invocation of /bin/bash -l.

@athrunsun
Copy link

@mintty Add that explicit invocation to where?

@mintty
Copy link
Owner

mintty commented Nov 5, 2017

To the end of the command line in the desktop shortcuts, or in your case, in the launch scripts *.bat.

@athrunsun
Copy link

@mintty Cool, it works. Thanks!

mintty added a commit that referenced this issue Nov 29, 2019
@mintty
Copy link
Owner

mintty commented Dec 2, 2019

Released 3.1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants