This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 189529

Summary: [PATCH] Terminal should invoke bash --login when invoking bash; should invoke bash, not sh, on Cygwin
Product: cnd Reporter: inonit <inonit>
Component: executionAssignee: ilia
Status: VERIFIED FIXED    
Severity: normal CC: err, markiewb
Priority: P3    
Version: 6.x   
Hardware: PC   
OS: Windows XP   
Issue Type: ENHANCEMENT Exception Reporter:
Attachments: Patch described in submission

Description inonit 2010-08-15 15:27:53 UTC
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.
Comment 1 inonit 2010-08-15 15:29:48 UTC
Created attachment 101400 [details]
Patch described in submission
Comment 2 ilia 2014-01-09 17:30:30 UTC
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.

Thank you!
=Ilia
Comment 3 inonit 2014-01-09 18:24:11 UTC
And thank you! Presumably this then gets included as an update to a plugin at some point?
Comment 4 ilia 2014-01-28 11:43:39 UTC
( fixed in
http://hg.netbeans.org/cnd-main/rev/e89f53c6c247 )
Comment 5 inonit 2014-02-14 19:13:12 UTC
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
login_shell     off

Can you confirm?
Comment 6 Alexander Simon 2014-02-14 19:20:40 UTC
(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:
http://bits.netbeans.org/download/trunk/nightly/latest/
Comment 7 soldatov 2014-03-21 20:35:53 UTC
verified in NetBeans IDE 7.4 (Build 20140320-3f80b6998498)
Comment 8 Quality Engineering 2014-03-26 17:05:23 UTC
Integrated into 'releases/release74', will be available in build *201403261440* or newer. Wait for official and publicly available build.

Changeset: http://hg.netbeans.org/releases/rev/1cb48d922294
User: Ilia Gromov <ilia@netbeans.org>
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)