-
Notifications
You must be signed in to change notification settings - Fork 914
Make sure netbeans in embedded terminal means itself #8756
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,12 +38,18 @@ cd "$progdir"/.. | |
| basedir=`pwd` | ||
| cd "$old" | ||
|
|
||
| case "`uname`" in | ||
| case "`uname -s -m`" in | ||
| Darwin*) | ||
| # set default userdir and cachedir on Mac OS X | ||
| DEFAULT_USERDIR_ROOT="${HOME}/Library/Application Support/NetBeans" | ||
| DEFAULT_CACHEDIR_ROOT=${HOME}/Library/Caches/NetBeans | ||
| ;; | ||
| CYGWIN*_64) | ||
| exec "$progdir/netbeans64.exe" "$@" | ||
| ;; | ||
| CYGWIN*) | ||
| exec "$progdir/netbeans.exe" "$@" | ||
| ;; | ||
| *) | ||
| # set default userdir and cachedir on unix systems | ||
| DEFAULT_USERDIR_ROOT=${HOME}/.netbeans | ||
|
|
@@ -65,8 +71,17 @@ fi | |
|
|
||
| export DEFAULT_USERDIR_ROOT | ||
|
|
||
| if ! [ "$NETBEANS_USERDIR" = "IGNORE" ]; then | ||
| # make sure own launcher directory is on PATH as a fallback | ||
| PATH=$PATH:$progdir | ||
| fi | ||
|
|
||
| # #68373: look for userdir, but do not modify "$@" | ||
| userdir="${netbeans_default_userdir}" | ||
| if [ -z "$NETBEANS_USERDIR" ]; then | ||
jtulach marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| userdir="${netbeans_default_userdir}" | ||
| else | ||
| userdir="$NETBEANS_USERDIR" | ||
| fi | ||
| cachedir="${netbeans_default_cachedir}" | ||
|
|
||
| founduserdir="" | ||
|
|
@@ -138,6 +153,8 @@ launchNbexec() { | |
| then | ||
| sh=/bin/bash | ||
| fi | ||
| NETBEANS_USERDIR=${userdir} | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| export NETBEANS_USERDIR | ||
| if [ "${founduserdir}" = "yes" ]; then | ||
| exec $sh "$nbexec" "$@" | ||
| else | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,6 +34,7 @@ | |
| using namespace std; | ||
|
|
||
| const char *NbLauncher::NBEXEC_FILE_PATH = NBEXEC_DLL; | ||
| const char *ENV_NETBEANS_USERDIR="NETBEANS_USERDIR"; | ||
| const char *NbLauncher::OPT_NB_DEFAULT_USER_DIR = "netbeans_default_userdir="; | ||
| const char *NbLauncher::OPT_NB_DEFAULT_CACHE_DIR = "netbeans_default_cachedir="; | ||
| const char *NbLauncher::OPT_NB_DEFAULT_OPTIONS = "netbeans_default_options="; | ||
|
|
@@ -74,6 +75,10 @@ int NbLauncher::start(char *cmdLine) { | |
| return start(args.getCount(), args.getArgs()); | ||
| } | ||
|
|
||
| const char* NbLauncher::findUserDirViaEnvVar() { | ||
| return getenv(ENV_NETBEANS_USERDIR); | ||
| } | ||
|
|
||
| int NbLauncher::start(int argc, char *argv[]) { | ||
| SetErrorMode(SetErrorMode(0) | SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); | ||
|
|
||
|
|
@@ -82,13 +87,26 @@ int NbLauncher::start(int argc, char *argv[]) { | |
| return -1; | ||
| } | ||
|
|
||
| parseConfigFile((baseDir + "\\etc\\" + getAppName() + ".conf").c_str()); | ||
| bool skipUserDir = false; | ||
| const char *userDirViaEnv = findUserDirViaEnvVar(); | ||
| if (userDirViaEnv != NULL) { | ||
| logMsg("NbLauncher::using NETBEANS_USERDIR env variable (%s)", userDirViaEnv); | ||
| string udve = userDirViaEnv; | ||
| if (udve == "IGNORE") { | ||
| skipUserDir = true; | ||
| userDirViaEnv = NULL; | ||
| } else { | ||
| userDir = userDirViaEnv; | ||
| } | ||
| } | ||
|
|
||
| parseConfigFile((baseDir + "\\etc\\" + getAppName() + ".conf").c_str(), userDirViaEnv == NULL); | ||
|
|
||
| if (!parseArgs(argc, argv)) { | ||
| return -1; | ||
| } | ||
| string oldUserDir = userDir; | ||
| parseConfigFile((userDir + "\\etc\\" + getAppName() + ".conf").c_str()); | ||
| parseConfigFile((userDir + "\\etc\\" + getAppName() + ".conf").c_str(), userDirViaEnv == NULL); | ||
| userDir = oldUserDir; | ||
|
|
||
| addExtraClusters(); | ||
|
|
@@ -114,6 +132,18 @@ int NbLauncher::start(int argc, char *argv[]) { | |
| if (!userDir.empty()) { | ||
| newArgs.add(ARG_NAME_USER_DIR); | ||
| newArgs.add(userDir.c_str()); | ||
| if (!skipUserDir) { | ||
| string toSet = ENV_NETBEANS_USERDIR; | ||
| toSet = toSet + "=" + userDir; | ||
| putenv(toSet.c_str()); | ||
|
|
||
| const char* path = getenv("PATH"); | ||
| if (path != NULL) { | ||
| string setPath = "PATH="; | ||
| setPath = setPath + path + ";" + baseDir + "\\bin\\"; | ||
| putenv(setPath.c_str()); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tested these changes with following program: package execenv;
public class ExecEnv {
public static void main(String[] args) throws Exception {
System.out.println("Env: " + System.getenv("PATH"));
var p = new ProcessBuilder("netbeans", "S:\\readme.txt").start();
var r = p.waitFor();
System.out.println("Res: " + r);
}
}when executed on NetBeans 27 it fails with: With changes in this PR it properly opens the file in the IDE executing the script. Setting |
||
| } | ||
| } | ||
| } | ||
| if (!defUserDirRoot.empty()) { | ||
| newArgs.add(ARG_DEFAULT_USER_DIR_ROOT); | ||
|
|
@@ -460,7 +490,7 @@ bool NbLauncher::getOption(char *&str, const char *opt) { | |
| return false; | ||
| } | ||
|
|
||
| bool NbLauncher::parseConfigFile(const char* path) { | ||
| bool NbLauncher::parseConfigFile(const char* path, const bool searchUserDir) { | ||
| logMsg("parseConfigFile(%s)", path); | ||
| FILE *file = fopen(path, "r"); | ||
| if (!file) { | ||
|
|
@@ -474,7 +504,7 @@ bool NbLauncher::parseConfigFile(const char* path) { | |
| if (*str == '#') { | ||
| continue; | ||
| } | ||
| if (getOption(str, getDefUserDirOptName())) { | ||
| if (searchUserDir && getOption(str, getDefUserDirOptName())) { | ||
| findUserDir(str); | ||
| logMsg("User dir: %s", userDir.c_str()); | ||
| } else if (getOption(str, getDefCacheDirOptName())) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--userdirCLIHandlerwon't be able to connect to the same NetBeans process