Browse Source

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

This patch was written by @pulkomandy. Thanks!

Reference Issue #7596.
Ryan C. Gordon 9 months ago
parent
commit
663411ff77
1 changed files with 6 additions and 2 deletions
  1. 6 2
      src/main/haiku/SDL_BeApp.cc

+ 6 - 2
src/main/haiku/SDL_BeApp.cc

@@ -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)) {