Cygwin uses bash as its primary shell: thus, it is counter-intuitive that NetBeans launches sh when running on Cygwin.
When invoking bash (on any platform), the argument --login should be sent to the shell in order to support reading of .bash_profile, etc.
The attached patch provides both of these changes.
Granted, it would be probably better to set up an elaborate UI to control login shell, environment, shell arguments, etc., but I don't know the NetBeans code base well enough to do that. So this is a start.
The only behavior change provided by this patch is that, by default, when running on Cygwin, the terminal emulator invokes [Cygwin]/bin/bash.exe --login, rather than [Cygwin]/bin/sh.exe. When running on other operating systems or with a non-Cygwin shell on Windows, the behavior is unchanged -- on those platforms, sh will continue to be invoked -- although the code is in place to pass --login to bash in other scenarios if it is chosen as the shell to invoke.
Although the Cygwin bash shortcut passes -i to the shell, it seems that Cygwin detects the NetBeans Terminal Window as a tty and thus it is not necessary to pass -i to obtain an interactive shell. (I've concluded this because I have been running a patched NetBeans for some time without the -i option and it works as expected.)
A more thorough reorganization of the code involved could be done, but I believe this patch minimally disturbs the existing code while maximally respecting its structure.
Created attachment 101400 [details]
Patch described in submission
inonit, I am very much obliged to you for the localized problem and offered patch
* problem with launching "bash" instead of "sh" when possible
I've found that problem have already been fixed in rev
262799:b52d6a5c9fe1 (Bug #213470 - Terminal not working properly with Cygwin)
* "bash --login" instead of "bash"
I applied part of your patch here.
Also I noticed a non-expected behavior when $USER or $HOSTNAME contain non-latin characters.
And thank you! Presumably this then gets included as an update to a plugin at some point?
( fixed in
Is this fix included in NetBeans 8.0 Beta?
If so, at least on my setup, it does not work:
Product Version: NetBeans IDE 8.0 Beta (Build 201401141042)
Java: 1.8.0; Java HotSpot(TM) 64-Bit Server VM 25.0-b69
Runtime: Java(TM) SE Runtime Environment 1.8.0-b129
System: Mac OS X version 10.8.5 running on x86_64; UTF-8; en_US (nb)
Output from within terminal:
bash-3.2$ shopt | grep login_shell
Can you confirm?
(In reply to inonit from comment #5)
> Is this fix included in NetBeans 8.0 Beta?
Of course the fix did not integrated in NetBeans 8.0 Beta.
You can try development build from:
verified in NetBeans IDE 7.4 (Build 20140320-3f80b6998498)
Integrated into 'releases/release74', will be available in build *201403261440* or newer. Wait for official and publicly available build.
User: Ilia Gromov <email@example.com>
Log: fixed Bug 189529 - [PATCH] Terminal should invoke bash --login when invoking bash; should invoke bash, not sh, on Cygwin
- "bash" -> "bash --login"
(transplanted from e89f53c6c247666a6d65f9264960807c79d71a5f)