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)
Sat, Jan 18, 7:29 AM
Unknown Object (File)
Nov 22 2024, 9:02 AM
Unknown Object (File)
Nov 22 2024, 6:17 AM
Unknown Object (File)
Nov 20 2024, 9:06 AM
Unknown Object (File)
Nov 18 2024, 8:41 AM
Unknown Object (File)
Nov 18 2024, 12:56 AM
Unknown Object (File)
Nov 17 2024, 5:48 PM
Unknown Object (File)
Nov 16 2024, 1:44 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.