]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
crunchgen: add --list option
authorMartin Tournoij <martin@arp242.net>
Wed, 17 Apr 2024 16:04:27 +0000 (10:04 -0600)
committerWarner Losh <imp@FreeBSD.org>
Wed, 17 Apr 2024 18:07:25 +0000 (12:07 -0600)
commitf122045e36dd009ecdc6b69a6f4b751c4b10b443
tree78ba27601bc79294a1670a5b54b00013c08bfd82
parent219b6e442308d5353b2af5f0771ce9b887b70754
crunchgen: add --list option

"bsdbox --list" will print all tools in the binary, one per line. The
main use case for this is to make it easier to create links:

for t in $(bsdbox --list); do
ln -s bsdbox $t
done

The name --list was taken from busybox.

This just adds a new "program" with the name "--list". I don't think we
need to do real argument parsing here, and this is also how busybox does
it.

An additional minor change is that just "bsdbox" will no longer print
the binary name itself ("bsdbox" in this case). Before it would do:

% bsdbox
usage: boxlike <prog> <args> ..., where <prog> is one of:
 cp ls mv bsdbox

And now just:

% bsdbox
usage: boxlike <prog> <args> ..., where <prog> is one of:
 cp ls mv

And just "bsdbox" will also exit with code 0 (and print to stdout)
rather than exit with 0 and print to stderr

Example output:

% ./bsdbox
usage: bsdbox program [args ...]
       bsdbox --list
       program [args ...]

bsdbox combines several programs in one executable. Create a link to this
executable with the program name to run that program, or give the program
name as the first argument.

Currently defined programs:
 true false tail head uname

% ./bsdbox --list
true
false
tail
head
uname

% ./bsdbox uname -a
FreeBSD freebsd 13.2-RELEASE-p4 FreeBSD 13.2-RELEASE-p4 GENERIC amd64

% ln -s bsdbox uname
% ./uname -a
FreeBSD freebsd 13.2-RELEASE-p4 FreeBSD 13.2-RELEASE-p4 GENERIC amd64

Pull Request: https://github.com/freebsd/freebsd-src/pull/894
Signed-off-by: Martin Tournoij <martin@arp242.net>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/894
usr.sbin/crunch/crunchgen/crunched_main.c
usr.sbin/crunch/crunchgen/crunchgen.c