dejagnu
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Stefan
Subject: Re: [PATCH] Catch errors properly, if whoami or who don't exist
Date: Thu, 12 Sep 2024 18:41:10 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.0

Hi!

As of commit 7be57b729931bbdfa0770eabe4e7586170b28b1f the problem should be fixed; please confirm that it is. (I took the opportunity to clean up the code while in there.)

Yes, confirmed.

There is a technical reason for this assumption about /bin/sh: the #! mechanism does not search $PATH and requires an absolute filename.

I know about this restriction, but this does not necessarily need to be 
extended to the script content itself.

In fact, how are you even running the dejagnu(1) and runtest(1) scripts if /bin/sh does not exist? Their #! lines refer to /bin/sh...

In Guix there is an automatism to patch (only) all shebangs to the correct 
absolute paths.

If you search for “ sh ” usage across the DejaGnu source, then you will find 
plenty of places happily using sh without /bin/.  But there is only this one 
usage of /bin/sh.  So for consistency one might argue to change it.

POSIX says otherwise, you must not rely on the presence of /bin/sh; cf. <https://pubs.opengroup.org/onlinepubs/9799919799/utilities/sh.html#tag_20_110_16>. The path to the interpreter can be easily substituted e.g. with autoconf.

That is in an informative section; and it is indeed correct that /bin/sh cannot be assumed to be a POSIX shell. The scripts that use #!/bin/sh in DejaGnu avoid making such an assumption. That section also says that you are supposed to be able to find a POSIX shell with `command -v sh` but I suspect that Autoconf does considerably more work than that to locate a suitable shell.

There is also confstr()¹, which is able to deliver a PATH, which is guaranteed to find sh.  And 
there is also a hint to “popen("command -p getconf variable", "r");”


Bye

Stefan


¹ <https://pubs.opengroup.org/onlinepubs/9699919799/functions/confstr.html>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]