@oh-my-pi/pi-utils 9.2.2 → 9.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/procmgr.ts +7 -7
package/package.json
CHANGED
package/src/procmgr.ts
CHANGED
|
@@ -17,9 +17,9 @@ const TERM_SIGNAL = IS_WINDOWS ? undefined : "SIGTERM";
|
|
|
17
17
|
/**
|
|
18
18
|
* Check if a shell binary is executable.
|
|
19
19
|
*/
|
|
20
|
-
|
|
20
|
+
function isExecutable(path: string): boolean {
|
|
21
21
|
try {
|
|
22
|
-
|
|
22
|
+
fs.accessSync(path, fs.constants.X_OK);
|
|
23
23
|
return true;
|
|
24
24
|
} catch {
|
|
25
25
|
return false;
|
|
@@ -90,14 +90,14 @@ function buildConfig(shell: string): ShellConfig {
|
|
|
90
90
|
* 3. On Unix: $SHELL if bash/zsh, then fallback paths
|
|
91
91
|
* 4. Fallback: sh
|
|
92
92
|
*/
|
|
93
|
-
export
|
|
93
|
+
export function getShellConfig(customShellPath?: string): ShellConfig {
|
|
94
94
|
if (cachedShellConfig) {
|
|
95
95
|
return cachedShellConfig;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
// 1. Check user-specified shell path
|
|
99
99
|
if (customShellPath) {
|
|
100
|
-
if (
|
|
100
|
+
if (fs.existsSync(customShellPath)) {
|
|
101
101
|
cachedShellConfig = buildConfig(customShellPath);
|
|
102
102
|
return cachedShellConfig;
|
|
103
103
|
}
|
|
@@ -119,7 +119,7 @@ export async function getShellConfig(customShellPath?: string): Promise<ShellCon
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
for (const path of paths) {
|
|
122
|
-
if (
|
|
122
|
+
if (fs.existsSync(path)) {
|
|
123
123
|
cachedShellConfig = buildConfig(path);
|
|
124
124
|
return cachedShellConfig;
|
|
125
125
|
}
|
|
@@ -144,7 +144,7 @@ export async function getShellConfig(customShellPath?: string): Promise<ShellCon
|
|
|
144
144
|
// Unix: prefer user's shell from $SHELL if it's bash/zsh and executable
|
|
145
145
|
const userShell = process.env.SHELL;
|
|
146
146
|
const isValidShell = userShell && (userShell.includes("bash") || userShell.includes("zsh"));
|
|
147
|
-
if (isValidShell &&
|
|
147
|
+
if (isValidShell && isExecutable(userShell)) {
|
|
148
148
|
cachedShellConfig = buildConfig(userShell);
|
|
149
149
|
return cachedShellConfig;
|
|
150
150
|
}
|
|
@@ -157,7 +157,7 @@ export async function getShellConfig(customShellPath?: string): Promise<ShellCon
|
|
|
157
157
|
for (const shellName of shellOrder) {
|
|
158
158
|
for (const dir of fallbackPaths) {
|
|
159
159
|
const shellPath = `${dir}/${shellName}`;
|
|
160
|
-
if (
|
|
160
|
+
if (isExecutable(shellPath)) {
|
|
161
161
|
cachedShellConfig = buildConfig(shellPath);
|
|
162
162
|
return cachedShellConfig;
|
|
163
163
|
}
|