Don't force POSIXLY_CORRECT. Reject extraneous argument

This commit is contained in:
наб 2021-11-28 01:40:23 +01:00
parent 49f0a05c33
commit e0b0de31b9
No known key found for this signature in database
GPG Key ID: BCFD0B018D2658F1

View File

@ -28,9 +28,6 @@ static int do_bare_main(
libzfs_print_on_error(libz, B_TRUE);
#if __GLIBC__
setenv("POSIXLY_CORRECT", "1", true);
#endif
auto gopts = reinterpret_cast<char *>(alloca(strlen(getoptions) + 2 + 1));
gopts[0] = 'h', gopts[1] = 'V';
strcpy(gopts + 2, getoptions);
@ -65,12 +62,14 @@ static int do_main(
return do_bare_main(
argc, argv, getoptions, usage, "dataset", getoptfn,
[&](auto libz) {
if(optind >= argc)
if(!*(argv + optind))
return fprintf(stderr,
"No dataset to act on?\n"
"Usage: %s [-hV] %s%sdataset\n",
argv[0], usage, strlen(usage) ? " " : ""),
__LINE__;
if(*(argv + optind + 1))
return fprintf(stderr, "Usage: %s [-hV] %s%sdataset\n", argv[0], usage, strlen(usage) ? " " : ""), __LINE__;
auto dataset = TRY_PTR(nullptr, zfs_open(libz, argv[optind], ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME));
quickscope_wrapper dataset_deleter{[&] { zfs_close(dataset); }};