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

Not execute the .profile file #56

Closed
futureproperty opened this issue Aug 25, 2017 · 16 comments
Closed

Not execute the .profile file #56

futureproperty opened this issue Aug 25, 2017 · 16 comments

Comments

@futureproperty
Copy link
Contributor

if I use bash.exe from powershell,it will excute the .profile(I have added "umask 022" line)

wsl2

but if use wsltty to launch wsl,it won't excute the .profile,like this:

wsl1

sorry for my bad english

@mintty
Copy link
Owner

mintty commented Aug 25, 2017

Do you use the initial Ubuntu on Windows installation or the newer one, installed from the Windows store?

@futureproperty
Copy link
Contributor Author

I installed wsl from Windows store.@mintty

@mintty
Copy link
Owner

mintty commented Sep 2, 2017

@rprichard, from my tests I have the impression that the wslbridge parameter -C~ does not work anymore.

@rprichard
Copy link

I just tested wslbridge -C~ with new versions of everything (Win10 16257, Windows Store's Ubuntu 16.04.2, and a new Cygwin install), and it worked fine.

FWIW: wslbridge doesn't start a bash login shell by default, but it looks like MS's bash.exe and ubuntu.exe do, so wslbridge should probably change. However, AFAICT wsltty already overrides wslbridge's default behavior by running bash -l explicitly, so it shouldn't matter.

I looked at the shortcuts created after installing wsltty 1.7.9, and I saw these command lines:

  • Ubuntu in Mintty: ...\mintty.exe ... /bin/wslbridge --distro-guid "{969399a6-ae69-4323-9733-bf056eb4c1aa}" -t /bin/bash
  • WSL % in Mintty: ...\mintty.exe ... /bin/wslbridge -t /bin/bash
  • WSL ~ in Mintty: ...\mintty.exe ... /bin/wslbridge -C~ -t /bin/bash
  • WSL -l in Mintty: ...\mintty.exe ... /bin/wslbridge -t /bin/bash -l

Bash will only source the profile/login scripts with wsltty's -l shortcut. wslbridge will change to the WSL home directory for only the ~ shortcut.

Suggestion: maybe all the shortcuts should use -l? ("WSL %" and "WSL ~" would then be identical, so maybe keep only one of them.)

@mintty
Copy link
Owner

mintty commented Sep 8, 2017

My confusion, sorry. -C~ is not supposed to invoke a login shell, nor are two of the three WSL shortcuts.
@futureproperty, which shortcut did you use?

This was designed on purpose to match the default behaviour of the original "Bash on Windows" WSL which did not invoke a login shell either. Now it seems that for the Ubuntu store WSL, the Windows bash.exe launcher seems to invoke a login shell. Hmm, not sure, what that means for the shortcut parameters that should be used. Is it dependent on the distribution; could it again be different for a different one; is it true at all? (to be checked)

@futureproperty
Copy link
Contributor Author

@mintty ,I used the shortcut in Start Menu.
"Start Menu\Programs\WSLtty\WSL ~ in Mintty.lnk"

@mintty
Copy link
Owner

mintty commented Sep 10, 2017

Obviously the bash.exe Windows launcher changed behaviour from the Legacy version (where it did not start a login shell as far as I remember), now it starts a login shell (as @rprichard already noted), so wsltty should change that.
This will also reduce the number of shortcuts/scripts to be installed and the associated potential confusion.
I can do that with a -l parameter, but maybe a login option in wslbridge would also be good, so $0 can be set to -bash as some people may expect to see.

@rprichard
Copy link

@mintty At the least, wslbridge should default to invoking bash as -bash. Do you think it should simply have an option to specify argv0 (e.g. rprichard/wslbridge#9)?

@mintty
Copy link
Owner

mintty commented Sep 10, 2017

I see no need to set an arbitrary $0. There should rather be a login option that applies the traditional Unix way, by prepending '-' to the invoked program name (basename) as $0. And I would not make it the default, to stay flexible and be consistent with other programs.

@mintty
Copy link
Owner

mintty commented Oct 23, 2017

Released 1.8.0 which does not request a particular shell anymore, so it does not manipulate the startup sequence.

@ksze
Copy link

ksze commented Dec 11, 2017

I don't understand the solution to this ticket.
I installed wsltty 1.8.1. By default, I still don't get a login shell that sources .profile when I launch the "Ubuntu Terminal" shortcut (the one without the "%" in the shortcut name). Am I supposed to modify the shortcut?

The "Target" of the shortcut currently looks like this:

%LOCALAPPDATA%\wsltty\bin\mintty.exe --WSL="Ubuntu" -h err --configdir="%APPDATA%\wsltty" -~ 

What am I supposed to change it to, so that I get a login shell?

@mintty
Copy link
Owner

mintty commented Dec 11, 2017

You could add an explicit invocation /bin/wslbridge -t /bin/bash -l or wait for wsltty 1.8.2 (planned soon).

@ksze
Copy link

ksze commented Jan 10, 2018

@mintty Where would I add the invocation? I tried to append /bin/wslbridge -t /bin/bash -l to the arguments of the "WSL Terminal" shortcut, but that just causes mintty to close immediately.

@mintty
Copy link
Owner

mintty commented Jan 10, 2018

Hmm. Apparently while optimizing the launch to need fewer parameters and support login mode (if available), the option to use the full invocation form was lost, sorry.

@mintty
Copy link
Owner

mintty commented Jan 10, 2018

Actually, it now works without referring to /bin/wslbridge explicitly:
...\mintty.exe --WSL=... --configdir=... -~ /bin/bash -l

@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

4 participants