[Tcsh] [PATCH] Fix: bug in "which" builtin
Jamie Landeg-Jones
jamie at catflap.org
Sun Feb 6 03:32:53 UTC 2022
(Re-sent with more appropriate subject line)
Damn! I just last night discovered a bug I was going to mention today!
Basically, I noticed my aliases were out of wack. I discovered that "which"
is no longer returning error 1 if a command is not found.
It seems that when "setcopy" was changed in some cases to "setstatus", a mistake
was made.
This is the fix:
--- tc.func.c.orig 2021-12-09 11:32:52.000000000 +0000
+++ tc.func.c 2022-02-02 07:23:26.065413000 +0000
@@ -503,7 +503,7 @@
rv &= cmd_expand(*v, NULL);
if (!rv)
- setstatus(0);
+ setstatus(1);
}
static int
I didn't check when this change occurred, but I plucked out a tc.func.c from 2016 and
did the following:
"tcsh" jamie at thompson% sdiff -s /tmp/tc.func.c tc.func.c | egrep 'setstatus|setcopy.STRstatus'
setcopy(STRstatus, STR1, VAR_READWRITE); | setstatus(0);
setcopy(STRstatus, STR1, VAR_READWRITE); | setstatus(1);
setcopy(STRstatus, STR0, VAR_READWRITE); | setstatus(0);
setcopy(STRstatus, STR1, VAR_READWRITE); | setstatus(1);
The inconsistency can be easily seen there.
Cheers, Jamie
More information about the Tcsh
mailing list