-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbash-add-localstatedir-bashrc-support.patch
104 lines (98 loc) · 3.1 KB
/
bash-add-localstatedir-bashrc-support.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
From b996925840dc4b0c004318db0ff22a33b95634d0 Mon Sep 17 00:00:00 2001
From: tinywrkb <[email protected]>
Date: Mon, 18 Jul 2022 15:49:48 +0300
Subject: [PATCH] add localstatedir bashrc support
---
config-top.h | 3 +++
shell.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 53 insertions(+), 2 deletions(-)
diff --git a/config-top.h b/config-top.h
index 2a437ba..7a7fe4a 100644
--- a/config-top.h
+++ b/config-top.h
@@ -95,6 +95,9 @@
/* System-wide .bashrc file for interactive shells. */
#define SYS_BASHRC "/usr/lib/sdk/devenv/etc/bash.bashrc"
+/* Local-state .bashrc file for interactive shells. */
+#define STATE_BASHRC "/var/lib/devenv/etc/bash.bashrc"
+
/* System-wide .bash_logout for login shells. */
#define SYS_BASH_LOGOUT "/usr/lib/sdk/devenv/etc/bash.bash_logout"
diff --git a/shell.c b/shell.c
index ce8087f..aa8fd2c 100644
--- a/shell.c
+++ b/shell.c
@@ -1102,6 +1102,8 @@ run_startup_files ()
int old_job_control;
#endif
int sourced_login, run_by_ssh;
+ int r;
+ char *devenv_prefix, *devenv_prefix_sdk, devenv_bashrc[PATH_MAX];
/* get the rshd/sshd case out of the way first. */
if (interactive_shell == 0 && no_rc == 0 && login_shell == 0 &&
@@ -1122,7 +1124,30 @@ run_startup_files ()
# if defined (__OPENNT)
maybe_execute_file (_prefixInstallPath(SYS_BASHRC, NULL, 0), 1);
# else
- maybe_execute_file (SYS_BASHRC, 1);
+ devenv_prefix = getenv("DEVENV_PREFIX");
+ devenv_prefix_sdk = getenv("DEVENV_PREFIX_SDK");
+ r = -1;
+
+ if ( devenv_prefix ) {
+ strcpy(devenv_bashrc, devenv_prefix);
+ strcat(devenv_bashrc, "/etc/bash.bashrc");
+ r = access(devenv_bashrc, F_OK);
+ }
+
+ if (r < 0 ) {
+ if ( access("/.flatpak-info", F_OK) == 0 ) {
+ if ( devenv_prefix_sdk &&
+ ( strcmp (devenv_prefix_sdk, "1") != 0 ) &&
+ access(STATE_BASHRC, F_OK) == 0 )
+ strcpy(devenv_bashrc, STATE_BASHRC);
+ else
+ strcpy(devenv_bashrc, SYS_BASHRC);
+ }
+ else
+ strcpy(devenv_bashrc, STATE_BASHRC);
+ }
+
+ maybe_execute_file (devenv_bashrc, 1);
# endif
#endif
maybe_execute_file (bashrc_file, 1);
@@ -1207,7 +1232,30 @@ run_startup_files ()
# if defined (__OPENNT)
maybe_execute_file (_prefixInstallPath(SYS_BASHRC, NULL, 0), 1);
# else
- maybe_execute_file (SYS_BASHRC, 1);
+ devenv_prefix = getenv("DEVENV_PREFIX");
+ devenv_prefix_sdk = getenv("DEVENV_PREFIX_SDK");
+ r = -1;
+
+ if ( devenv_prefix ) {
+ strcpy(devenv_bashrc, devenv_prefix);
+ strcat(devenv_bashrc, "/etc/bash.bashrc");
+ r = access(devenv_bashrc, F_OK);
+ }
+
+ if (r < 0 ) {
+ if ( access("/.flatpak-info", F_OK) == 0 ) {
+ if ( devenv_prefix_sdk &&
+ ( strcmp (devenv_prefix_sdk, "1") != 0 ) &&
+ access(STATE_BASHRC, F_OK) == 0 )
+ strcpy(devenv_bashrc, STATE_BASHRC);
+ else
+ strcpy(devenv_bashrc, SYS_BASHRC);
+ }
+ else
+ strcpy(devenv_bashrc, STATE_BASHRC);
+ }
+
+ maybe_execute_file (devenv_bashrc, 1);
# endif
#endif
maybe_execute_file (bashrc_file, 1);
--
2.37.3