about summary refs log tree commit diff stats
path: root/src/wrapped/wrappedlibc.c
diff options
context:
space:
mode:
authorYang Liu <liuyang22@iscas.ac.cn>2025-09-03 03:18:30 +0800
committerGitHub <noreply@github.com>2025-09-02 21:18:30 +0200
commit94c40d99f61fccdaa95ad4a8081e61a733f6a192 (patch)
tree7f2f225ee191911705310a39c851d508d9cc1b41 /src/wrapped/wrappedlibc.c
parent28d07f9bf03c76013db8d15477e8d1f46d1b930d (diff)
downloadbox64-94c40d99f61fccdaa95ad4a8081e61a733f6a192.tar.gz
box64-94c40d99f61fccdaa95ad4a8081e61a733f6a192.zip
[BASH] Use custom PS1 prefix to make box64-bash more distinguishable (#2998)
* [BASH] Use custom PS1 prefix to make box64-bash more distinguishable

* quick fix

* tweaks

* review
Diffstat (limited to 'src/wrapped/wrappedlibc.c')
-rw-r--r--src/wrapped/wrappedlibc.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/wrapped/wrappedlibc.c b/src/wrapped/wrappedlibc.c
index 742ae677..4fa9ed62 100644
--- a/src/wrapped/wrappedlibc.c
+++ b/src/wrapped/wrappedlibc.c
@@ -1956,6 +1956,19 @@ EXPORT int32_t my_open(x64emu_t* emu, void* pathname, int32_t flags, uint32_t mo
         return -1;
     }
     #endif
+
+    if (!strcmp((const char*)pathname, "box64-custom-bashrc-file")) {
+        int tmp = shm_open("box64-custom-bashrc-file", O_RDWR | O_CREAT, S_IRWXU);
+        if (tmp < 0) return open(pathname, flags, mode); // error fallback
+        shm_unlink("box64-custom-bashrc-file");
+        const char* content = "if [ -f ~/.bashrc ]\nthen\n. ~/.bashrc\nfi\nexport PS1=\"(box64) \"$PS1\nexport BOX64_NOBANNER=1\nexport BOX64_LOG=0\n";
+        size_t dummy;
+        dummy = write(tmp, content, strlen(content));
+        (void)dummy;
+        lseek(tmp, 0, SEEK_SET);
+        return tmp;
+    }
+
     int ret = open(pathname, flags, mode);
     return ret;
 }