Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F102128855
D44405.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D44405.diff
View Options
diff --git a/sbin/bectl/bectl.8 b/sbin/bectl/bectl.8
--- a/sbin/bectl/bectl.8
+++ b/sbin/bectl/bectl.8
@@ -13,7 +13,7 @@
.\" documentation and/or other materials provided with the distribution.
.\"
.\"
-.Dd October 5, 2023
+.Dd March 18, 2024
.Dt BECTL 8
.Os
.Sh NAME
@@ -21,7 +21,7 @@
.Nd Utility to manage boot environments on ZFS
.Sh SYNOPSIS
.Nm
-.Op Fl h\&?
+.Op Fl h
.Nm
.Op Fl r Ar beroot
.Cm activate
@@ -115,10 +115,9 @@
.Ss Supported Subcommands and Flags
.Bl -tag -width activate
.It Xo
-.Fl h |
-.Fl \&?
+.Fl h
.Xc
-Print usage information.
+Print usage information and exit.
.It Xo
.Cm activate
.Op Fl t | Fl T
diff --git a/sbin/bectl/bectl.c b/sbin/bectl/bectl.c
--- a/sbin/bectl/bectl.c
+++ b/sbin/bectl/bectl.c
@@ -64,7 +64,7 @@
fp = explicit ? stdout : stderr;
fprintf(fp, "%s",
- "Usage:\tbectl {-h | -? | subcommand [args...]}\n"
+ "Usage:\tbectl {-h | subcommand [args...]}\n"
#if SOON
"\tbectl [-r beroot] add (path)*\n"
#endif
@@ -545,27 +545,31 @@
{
struct command_map_entry *cmd;
const char *command;
- char *root;
- int rc;
+ char *root = NULL;
+ int opt, rc;
- cmd = NULL;
- root = NULL;
- if (argc < 2)
- return (usage(false));
-
- if (strcmp(argv[1], "-r") == 0) {
- if (argc < 4)
- return (usage(false));
- root = strdup(argv[2]);
- command = argv[3];
- argc -= 3;
- argv += 3;
- } else {
- command = argv[1];
- argc -= 1;
- argv += 1;
+ while ((opt = getopt(argc, argv, "hr:")) != -1) {
+ switch (opt) {
+ case 'h':
+ exit(usage(true));
+ case 'r':
+ root = strdup(optarg);
+ break;
+ default:
+ exit(usage(false));
+ }
}
+ argc -= optind;
+ argv += optind;
+
+ if (argc == 0)
+ exit(usage(false));
+
+ command = *argv;
+ optreset = 1;
+ optind = 1;
+
/* Handle command aliases */
if (strcmp(command, "umount") == 0)
command = "unmount";
@@ -573,9 +577,6 @@
if (strcmp(command, "ujail") == 0)
command = "unjail";
- if ((strcmp(command, "-?") == 0) || (strcmp(command, "-h") == 0))
- return (usage(true));
-
if ((cmd = get_cmd_info(command)) == NULL) {
fprintf(stderr, "Unknown command: %s\n", command);
return (usage(false));
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 8, 11:37 PM (21 h, 41 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14545368
Default Alt Text
D44405.diff (2 KB)
Attached To
Mode
D44405: bectl: Use geopt() and drop mention of -?.
Attached
Detach File
Event Timeline
Log In to Comment