Skip to content

Commit 44257b7

Browse files
committed
Shell: don't try to get arg1 if python was executed without extra args
1 parent d7e9094 commit 44257b7

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/common/processing_linux.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -166,15 +166,16 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons
166166
do arg0++; while (*arg0 == '\0');
167167
assert(arg0 < procArgs2 + len);
168168

169+
if (argc > 1)
169170
{
170171
// #977
171-
char* p = (char*) strrchr(arg0, '/');
172+
const char* p = strrchr(arg0, '/');
172173
if (p)
173-
{
174174
p++;
175-
if (ffStrStartsWithIgnCase(p, "python")) // /opt/homebrew/Cellar/[email protected]/3.12.3/Frameworks/Python.framework/Versions/3.12/Resources/Python.app/Contents/MacOS/Python /Users/carter/.local/bin/xonsh
176-
arg0 = p + strlen(p) + 1;
177-
}
175+
else
176+
p = arg0;
177+
if (ffStrStartsWithIgnCase(p, "python")) // /opt/homebrew/Cellar/[email protected]/3.12.3/Frameworks/Python.framework/Versions/3.12/Resources/Python.app/Contents/MacOS/Python /Users/carter/.local/bin/xonsh
178+
arg0 = p + strlen(p) + 1;
178179
}
179180

180181
if (*arg0 == '-') arg0++; // Login shells
@@ -221,12 +222,12 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons
221222
{
222223
char* p = (char*) memrchr(args, '/', arg0Len);
223224
if (p)
224-
{
225225
p++;
226-
if (ffStrStartsWith(p, "python")) // /usr/local/bin/python3.9 /home/carter/.local/bin/xonsh
227-
{
228-
arg0 += arg0Len + 1;
229-
}
226+
else
227+
p = arg0;
228+
if (ffStrStartsWith(p, "python")) // /usr/local/bin/python3.9 /home/carter/.local/bin/xonsh
229+
{
230+
arg0 += arg0Len + 1;
230231
}
231232
}
232233
if (arg0[0] == '-') arg0++;

0 commit comments

Comments
 (0)