From c45f0388350bd6f0cde2ec2abc0e5df523e766f5 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Mon, 21 Sep 2020 19:33:10 -0700 Subject: [PATCH] remove direct use of environ This code was manually parsing environment variable settings for some reason. It also (incorrectly) assumed $_ would always be the first environment variable. --- lib/ast/pathpath.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ast/pathpath.c b/lib/ast/pathpath.c index 6feb1e882..458beed54 100644 --- a/lib/ast/pathpath.c +++ b/lib/ast/pathpath.c @@ -82,8 +82,8 @@ char *pathpath(char *path, const char *p, const char *a, int mode) (strchr(s, '/') || (((s = cmd) || (opt_info_argv && (s = *opt_info_argv))) && strchr(s, '/') && !strchr(s, '\n') && !access(s, F_OK)) || - (environ && (s = *environ) && *s++ == '_' && - *s++ == '=' && strchr(s, '/') && !strneq(s, "/bin/", 5) && + ((s = getenv("_")) && + strchr(s, '/') && !strneq(s, "/bin/", 5) && !strneq(s, "/usr/bin/", 9)) || (*x && !access(x, F_OK) && (s = getenv("PWD")) && *s == '/') ) -- 2.50.1