From e63febac3a45d4bd8f7e06ec2b4464af0d23b377 Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Thu, 25 Jan 2024 21:33:28 +0000 Subject: [PATCH] command -x: fix bypassing path-bound built-ins again (re: be79e4e9) Symptom, after compiling ksh with support for dynamic libraries (this will again become possible soon, we're currently testing it), if the virtual /opt/ast/bin directory for path-bound built-ins is first in $PATH: $ ksh -c 'command -vx cat; command -vx cat' /opt/ast/bin/cat /bin/cat This already showed up in a regression test failure for the dynamically linked ksh: path.sh[1008]: FAIL: 'command -vx' breakage (expected status 0, /bin/cat; got status 0, /opt/ast/bin/cat) src/cmd/ksh93/sh/path.c: path_absolute(): - Add missing check for SH_XARG shell state bit. --- src/cmd/ksh93/sh/path.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/ksh93/sh/path.c b/src/cmd/ksh93/sh/path.c index f5fbb2402057..1524cd33c533 100644 --- a/src/cmd/ksh93/sh/path.c +++ b/src/cmd/ksh93/sh/path.c @@ -800,7 +800,7 @@ Pathcomp_t *path_absolute(const char *name, Pathcomp_t *pp, int flag) np->nvenv = dll; goto found; } - if(*stkptr(sh.stk,PATH_OFFSET)=='/' && nv_search(stkptr(sh.stk,PATH_OFFSET),sh.bltin_tree,0)) + if(!sh_isstate(SH_XARG) && *stkptr(sh.stk,PATH_OFFSET)=='/' && nv_search(stkptr(sh.stk,PATH_OFFSET),sh.bltin_tree,0)) goto found; if(fp) free(fp);