Re: [PATCH] Catch errors properly, if whoami or who don't exist

Jacob Bachmeyer <[email protected]> Wed, 04 Sep 2024 19:27:49 -0500
Newsgroups gmane.comp.sysutils.dejagnu.general
Message-ID <[email protected]>
Stefan wrote:
> Catch got passed a string in which the command substitution happened 
> before,
> so it could not catch the error thrown by 'exec'. The string match for 
> error
> messages afterwards was relying on an english language setting and did 
> not
> even match the english error message of whoami from coreutils.

Can you provide more information about your environment, in particular 
how whoami(1) failed?

This code dates back to the beginning of the repository history and 
ChangeLog-1992 suggests that it likely originated in 1993 or 1994.  
Those error messages presumably are from some particular (now archaic) 
environment that did not have whoami(1), but unless Tcl's evaluation 
semantics have changed, this misuse of catch(n) should have blown up 
then, too.  I am a bit confused how this could have gone unnoticed for 
so long.  If you are actually the first person to have tried running 
DejaGnu on a system lacking both of the USER and LOGNAME environment 
variables and the whoami(1) command, I am not sure that the fallback for 
a missing whoami(1) is still relevant.  (If it never worked, then I am 
unsure that it was ever relevant.)

On a side note, a thorough audit of the code base for misuses of 
eval-like commands (including catch) is planned as the solution to 
PR44602 (DejaGnu fails if run in a directory where the full absolute 
name contains spaces).


-- Jacob