From a0ca5a4fc4ec3e6874eda96e5d2d65fc9a2e6fa7 Mon Sep 17 00:00:00 2001 From: Ralph Little Date: Mon, 21 Feb 2022 22:13:28 +0000 Subject: [PATCH] Resolve "[hp5590] Read only values aren't accessible via CLI options (unrecognized option)" --- frontend/scanimage.c | 12 +++++++++--- newsfragments/scanimage_readonly.frontend | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 newsfragments/scanimage_readonly.frontend diff --git a/frontend/scanimage.c b/frontend/scanimage.c index b587b9d89..937a72078 100644 --- a/frontend/scanimage.c +++ b/frontend/scanimage.c @@ -917,9 +917,9 @@ fetch_options (SANE_Device * device) scanimage_exit (1); } - /* create command line option only for settable options */ - if (!SANE_OPTION_IS_SETTABLE (opt->cap) || opt->type == SANE_TYPE_GROUP) - continue; + /* create command line option only for non-group options */ + if (opt->type == SANE_TYPE_GROUP) + continue; option_number[option_count] = i; @@ -1072,6 +1072,12 @@ process_backend_option (SANE_Handle device, int optnum, const char *optarg) opt = sane_get_option_descriptor (device, optnum); + if (!SANE_OPTION_IS_SETTABLE (opt->cap)) + { + fprintf (stderr, "%s: attempted to set readonly option %s\n", + prog_name, opt->name); + scanimage_exit (1); + } if (!SANE_OPTION_IS_ACTIVE (opt->cap)) { fprintf (stderr, "%s: attempted to set inactive option %s\n", diff --git a/newsfragments/scanimage_readonly.frontend b/newsfragments/scanimage_readonly.frontend new file mode 100644 index 000000000..8dddeb7e0 --- /dev/null +++ b/newsfragments/scanimage_readonly.frontend @@ -0,0 +1 @@ +scanimage: Attempts to set readonly options will give a warning about readonly option set attempt now, instead of the misleading "unknown option" error.