-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
zfs program doesn't pass arguments that begin with dash (-) to channel program #9056
Comments
@clinta I was initially a little confused by the title/description so I adjusted the wording in the bug report. I agree that what you're trying to do should work, as described in the usage message: flags for the CLI go directly after |
Note that this bug is specific to Linux, due to the way getopt() works. On illumos, it has the expected result. The problem is that Linux getopt() skips non-flag arguments, but illumos getopt() stops processing when encountering a non-flag argument. This behavior has implications for other subcommands as well. |
The default Linux GNU index 53b76e25d6a6..23d3cea903ac 100644
--- a/cmd/zfs/zfs_main.c
+++ b/cmd/zfs/zfs_main.c
@@ -7628,7 +7628,7 @@ zfs_do_channel_program(int argc, char **argv)
zpool_handle_t *zhp;
/* check options */
- while ((c = getopt(argc, argv, "nt:m:j")) != -1) {
+ while ((c = getopt(argc, argv, "+nt:m:j")) != -1) {
switch (c) {
case 't':
case 'm': { It may be worth applying the prefix to every subcommand to ensure the behavior is identical across all OpenZFS platforms. Though it could break existing scripts which unknowingly depend on the GNU getopt behavior. I'm also not sure how illumos / FreeBSD would interpret the prefix so it may make the code itself less portable. Reference:
|
I discovered a side effect. Trying to fix this caused the Those tests expect |
I've suggested a small documentation update to resolve this issue in #9428. It's my understanding that the slightly modified syntax should work on Linux, FreeBSD, and Illumos. |
Update the zfs(8) man page to clearly describe that arguments for channel programs are to be listed after the -- sentinel which terminates argument processing. This behavior is supported by getopt on Linux, FreeBSD, and Illumos according to each platforms respective man pages. zfs program [-jn] [-t instruction-limit] [-m memory-limit] pool script [--] arg1 ... Reviewed-by: Clint Armstrong <clint@clintarmstrong.net> Reviewed-by: George Melikov <mail@gmelikov.ru> Reviewed-by: loli10K <ezomori.nozomu@gmail.com> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes openzfs#9056 Closes openzfs#9428
Update the zfs(8) man page to clearly describe that arguments for channel programs are to be listed after the -- sentinel which terminates argument processing. This behavior is supported by getopt on Linux, FreeBSD, and Illumos according to each platforms respective man pages. zfs program [-jn] [-t instruction-limit] [-m memory-limit] pool script [--] arg1 ... Reviewed-by: Clint Armstrong <clint@clintarmstrong.net> Reviewed-by: George Melikov <mail@gmelikov.ru> Reviewed-by: loli10K <ezomori.nozomu@gmail.com> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes openzfs#9056 Closes openzfs#9428
Update the zfs(8) man page to clearly describe that arguments for channel programs are to be listed after the -- sentinel which terminates argument processing. This behavior is supported by getopt on Linux, FreeBSD, and Illumos according to each platforms respective man pages. zfs program [-jn] [-t instruction-limit] [-m memory-limit] pool script [--] arg1 ... Reviewed-by: Clint Armstrong <clint@clintarmstrong.net> Reviewed-by: George Melikov <mail@gmelikov.ru> Reviewed-by: loli10K <ezomori.nozomu@gmail.com> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #9056 Closes #9428
System information
Describe the problem you're observing
The
zfs channel
CLI subcommand consumes any arguments that being with-
, without passing them to the actual channel program.Describe how to reproduce the problem
Expected result:
The text was updated successfully, but these errors were encountered: