HomeFreeBSD

lorder: Clean up and improve robustness.

Description

lorder: Clean up and improve robustness.

  • Properly parse (no) command-line options.
  • Ensure that errors go to stderr and result in a non-zero exit.
  • Drop the special-case code for a single argument, as it will produce the wrong outcome if the file does not exist or is corrupted.
  • Don't print anything until after we've collected all the data.
  • Always create all temporary files before setting the trap. This ensures that the trap can safely fire at any moment, regardless of any previous definition of T.
  • Use a temporary file rather than a pipe between nm and sed to ensure proper termination if nm fails due to a missing or invalid input.
  • The check for self-referential entries was conditional on testing our argument list against a regex looking for archives. This was a needless and unreliable optimization; make the check unconditional.
  • Document that lorder will not work properly if any of its inputs have spaces in their name.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: allanjude
Differential Revision: https://reviews.freebsd.org/D44133

(cherry picked from commit 5c7b986c21ed47545203e8f630fe2281b83112d2)

lorder: Add unit tests.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: allanjude
Differential Revision: https://reviews.freebsd.org/D44134

(cherry picked from commit 96da41b6dbf383436018f11ad8a672faab2d3789)

lorder: Undeprecate.

While lorder is not required by our current toolchain (or any toolchain
we've used in the past decade or two), it still occasionally shows up
in build systems of third party software, including The Open Group's
UNIX conformance test suite, and the maintenance cost is negligible.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: imp, allanjude, emaste
Differential Revision: https://reviews.freebsd.org/D44135

(cherry picked from commit cf4d9bf8b38819da12c6d686d5cf6dbd6353cd61)

lorder: Don't rely on legacy syntax.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: allanjude
Differential Revision: https://reviews.freebsd.org/D44155

(cherry picked from commit aedb37dc49319a7cd1faf34f312a8a9fc01e611d)

lorder: Tweak invalid file test.

Different implementations of nm have different ways of telling you
that your file is not a valid object or library, but they all seem to
have “not recognized” as a common substring.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: allanjude
Differential Revision: https://reviews.freebsd.org/D44154

(cherry picked from commit aa80cfadff0bb715ca090cbd1b3561a1619251d5)

Details

Provenance
desAuthored on Feb 28 2024, 3:37 PM
Reviewer
allanjude
Differential Revision
D44133: lorder: Clean up and improve robustness.
Parents
rGda2905289748: diff: Fix --expand-tabs and --side-by-side.
Branches
Unknown
Tags
Unknown