]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
lorder: Clean up and improve robustness.
authorDag-Erling Smørgrav <des@FreeBSD.org>
Wed, 28 Feb 2024 15:37:36 +0000 (16:37 +0100)
committerDag-Erling Smørgrav <des@FreeBSD.org>
Wed, 28 Feb 2024 15:37:36 +0000 (16:37 +0100)
commit5c7b986c21ed47545203e8f630fe2281b83112d2
tree7aef7e6c58057e9696fa6b7513ae2520fd99b1d9
parentcb4a83cff01cdf871c78115c942c5b34412914d2
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
usr.bin/lorder/lorder.1
usr.bin/lorder/lorder.sh