From ae64d6a01d8ad8a8de7ce542933a3f7e6fa73ad4 Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Sun, 9 Jan 2022 09:42:26 -0800 Subject: [PATCH] vm: only set cwd when not on a terminal --- vm/os-macosx.mm | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/vm/os-macosx.mm b/vm/os-macosx.mm index 4f1944a90c..bf41074ddb 100644 --- a/vm/os-macosx.mm +++ b/vm/os-macosx.mm @@ -2,6 +2,8 @@ #include #include +#include +#include #include "master.hpp" @@ -39,8 +41,10 @@ const char* default_image_path(void) { if ([path hasSuffix:@".app"] || [path hasSuffix:@".app/"]) { NSFileManager* mgr = [NSFileManager defaultManager]; - NSString* root = [path stringByDeletingLastPathComponent]; - [mgr changeCurrentDirectoryPath: root]; + if (!isatty(fileno(stdin))) { + NSString* root = [path stringByDeletingLastPathComponent]; + [mgr changeCurrentDirectoryPath: root]; + } NSString* imageInBundle = [[path stringByAppendingPathComponent:@"Contents/Resources"] @@ -50,13 +54,7 @@ const char* default_image_path(void) { returnVal = ([mgr fileExistsAtPath:imageInBundle] ? imageInBundle : imageAlongBundle); - } else if ([executablePath hasSuffix:@".app/Contents/MacOS/factor"]) { - returnVal = executablePath; - returnVal = [returnVal stringByDeletingLastPathComponent]; - returnVal = [returnVal stringByDeletingLastPathComponent]; - returnVal = [returnVal stringByDeletingLastPathComponent]; - returnVal = [returnVal stringByDeletingLastPathComponent]; - returnVal = [returnVal stringByAppendingPathComponent:image]; + } else { returnVal = [path stringByAppendingPathComponent:image]; } -- 2.34.1