haiku: Don't change the cwd on startup if launched from a Terminal.

This patch was written by @pulkomandy. Thanks!

Reference Issue #7596.
This commit is contained in:
Ryan C. Gordon
2024-07-11 11:41:14 -04:00
parent a2215ff81c
commit 663411ff77

View File

@@ -118,9 +118,13 @@ static int StartBeLooper()
} while ((!be_app) || be_app->IsLaunching());
}
/* Change working directory to that of executable */
/* If started from the GUI, change working directory to that of executable.
* This matches behavior on other platforms and may be needed by some SDL software.
* Don't do it when started from terminal (TERM environment variable is set), because in that
* case, the current directory may be important, and after this there will be no way to know
* what it was. */
app_info info;
if (B_OK == be_app->GetAppInfo(&info)) {
if (NULL == getenv("TERM") && B_OK == be_app->GetAppInfo(&info)) {
entry_ref ref = info.ref;
BEntry entry;
if (B_OK == entry.SetTo(&ref)) {