Page MenuHomeFreeBSD

rc.subr add Exists so we can find sed
ClosedPublic

Authored by sjg on Feb 11 2024, 1:01 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Oct 14, 6:09 PM
Unknown Object (File)
Tue, Oct 14, 6:09 PM
Unknown Object (File)
Tue, Oct 14, 6:09 PM
Unknown Object (File)
Tue, Oct 14, 6:09 PM
Unknown Object (File)
Tue, Oct 14, 6:26 AM
Unknown Object (File)
Thu, Oct 2, 10:30 AM
Unknown Object (File)
Wed, Oct 1, 12:21 PM
Unknown Object (File)
Wed, Oct 1, 4:59 AM
Subscribers

Details

Summary

SED=Exists -x /usr/bin/sed /rescue/sed

avoids adding /rescure to $PATH, and allows use of sed
before /usr is mounted (if a separate filesystem).

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

sjg requested review of this revision.Feb 11 2024, 1:01 AM
sjg created this revision.

This looks good. It makes an extra effort to find sed.
I just wonder if it is possible to define SED=${SED:-$(Exists -x /usr/bin/sed /rescue/sed)} only once in rc.subr, maybe at the beginning?
ShellCheck usually recommends avoiding backticks (https://www.shellcheck.net/wiki/SC2006).

In D43826#999880, @jlduran_gmail.com wrote:

This looks good. It makes an extra effort to find sed.
I just wonder if it is possible to define SED=${SED:-$(Exists -x /usr/bin/sed /rescue/sed)} only once in rc.subr, maybe at the beginning?

we could but it is only needed if /usr isn't mounted which is checked by have basename
the extra SED=${SED:- in rc_trace is just incase that is called from local.rc.subr before we check for basename.

ShellCheck usually recommends avoiding backticks (https://www.shellcheck.net/wiki/SC2006).

old habits...

Use $() rather than backticks, and only look once.

This revision is now accepted and ready to land.Feb 12 2024, 4:04 AM
This revision was automatically updated to reflect the committed changes.