From: Zbigniew Jędrzejewski-Szmek Date: Sat, 4 Apr 2026 18:38:52 +0000 (+0200) Subject: shared/options: quote the metavar in --help output X-Git-Tag: v261-rc1~574^2~11 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e59fea008841c0050297692109922b4a34fe8dba;p=thirdparty%2Fsystemd.git shared/options: quote the metavar in --help output imdsd uses --extra-header='NAME: VALUE'. We could include the quotes in the metavar string, but I think it's nicer to only do that in the printed output, so that later, when we add introspection, the value there will not include the quotes. --- diff --git a/src/shared/options.c b/src/shared/options.c index e6b82fe34d0..f94ba284321 100644 --- a/src/shared/options.c +++ b/src/shared/options.c @@ -297,6 +297,7 @@ int _option_parser_get_help_table( * "=" is shown only when a long option is defined: -l --long=ARG, --long=ARG, -s ARG. */ bool need_eq = option_takes_arg(opt) && opt->long_code; + bool need_quote = opt->metavar && strchr(opt->metavar, ' '); _cleanup_free_ char *s = strjoin( " ", sc, @@ -305,7 +306,9 @@ int _option_parser_get_help_table( strempty(opt->long_code), option_arg_optional(opt) ? "[" : "", need_eq ? "=" : "", + need_quote ? "'" : "", strempty(opt->metavar), + need_quote ? "'" : "", option_arg_optional(opt) ? "]" : ""); if (!s) return log_oom();