Re: eval: startmsg: not found on FreeBSD 14.2-RELEASE-p1

From: Frank Leonhardt <freebsd-doc_at_fjl.co.uk>
Date: Sat, 22 Feb 2025 15:19:40 UTC
On 19/02/2025 10:45, Mario Marietto wrote:
> Hello.
>
> Sorry for the mistake,I have /etc/rc.subr. This is the part of the 
> code that may be correlated with the error that I get. Should I modify 
> it ? How ?
>
> #
> # check_startmsgs
> # If rc_quiet is set (usually as a result of using faststart at
> # boot time) check if rc_startmsgs is enabled.
> #
> check_startmsgs()
> {
> if [ -n "$rc_quiet" ]; then
> checkyesno rc_startmsgs
> else
> return 0
> fi
> }
>
> This is the full code of rc.subr :
> <snip>
> -- 
> Mario.

I don't recognise this problem but as no one has answered I've spent a 
few minutes looking at it.

I've checked 14.2-RELEASE and "startmsg" exists in /etc/rc.subr so this 
probably isn't the same problem. I'm going to assume you don't do much 
in the way of shell scripts - apologies if you do.

startmsg() is a function that optionally prints out a message after 
checking to see if they’re suppressed. It's a wrapper around the 
standard shell echo.

The problem here is that something appears to be calling it but isn't 
finding it. I'd love to know what, but I can't figure it out. I've not 
looked deeply into the FreeBSD pkg system - I'm from a time when 
everything was compiled from source code and that's bad enough!

pkg itself isn't a script but I guess it's calling something that is, 
and this is failing to include /etc/rc.subr so startmsg() is never found.

Quick hack. From sh as root user.

# echo "#!/bin/sh" >/bin/startmsg
# echo 'echo "$@"' >>/bin/startmsg
# chmod a+x /bin/startmsg

This will make the startmsg function available to all scripts. Try 
again. After use get rid of it:

# rm /bin/startmsg

If you're in csh instead of sh you'll have to put a \ in front of the ! 
in the first line:  echo "#\!/bin/sh" >/bin/startmsg

I suspect that if the mystery script is failing to find startmsg() it 
will fail to find something else after it's been hacked but it's worth a 
shot.

Regards, Frank.