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
F102701042: D43826.id134232.diff
Sat, Nov 16, 1:26 AM
Unknown Object (File)
Sun, Nov 10, 10:47 AM
Unknown Object (File)
Sun, Nov 10, 9:00 AM
Unknown Object (File)
Sat, Nov 9, 8:21 AM
Unknown Object (File)
Oct 9 2024, 1:57 PM
Unknown Object (File)
Sep 12 2024, 9:17 AM
Unknown Object (File)
Sep 8 2024, 8:24 PM
Unknown Object (File)
Sep 8 2024, 6:55 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.