22
33 Copyright (C) 1999 Russell Kroll <rkroll@exploits.org>
44 Copyright (C) 2012 Arnaud Quette <arnaud.quette@free.fr>
5- Copyright (C) 2020-2025 Jim Klimov <jimklimov+nut@gmail.com>
5+ Copyright (C) 2020-2026 Jim Klimov <jimklimov+nut@gmail.com>
66
77 This program is free software; you can redistribute it and/or modify
88 it under the terms of the GNU General Public License as published by
@@ -48,14 +48,14 @@ static void fatalx_error_json_simple(int msg_is_simple, const char *msg) {
4848 if (output_json ) {
4949 if (msg_is_simple ) {
5050 /* Caller knows there is nothing to escape here, pass through */
51- printf ("{\"error\": \"%s\"}\n" , msg );
51+ printf ("{\"error\": \"%s\"}\n" , NUT_STRARG ( msg ) );
5252 } else {
5353 printf ("{\"error\": \"" );
5454 json_print_esc (msg );
5555 printf ("\"}\n" );
5656 }
5757 }
58- fatalx (EXIT_FAILURE , "Error: %s" , msg );
58+ fatalx (EXIT_FAILURE , "Error: %s" , NUT_STRARG ( msg ) );
5959}
6060
6161static void usage (const char * prog )
@@ -91,6 +91,7 @@ static void usage(const char *prog)
9191 printf (" -h - display this help text\n" );
9292
9393 nut_report_config_flags ();
94+ upscli_report_build_details ();
9495
9596 printf ("\n%s" , suggest_doc_links (prog , NULL ));
9697}
@@ -168,6 +169,8 @@ static void list_vars(void)
168169 int msg_is_simple = 1 ;
169170
170171 /* check for an old upsd */
172+ upsdebugx (1 , "%s: got code %d, upserror %d" ,
173+ __func__ , ret , upscli_upserror (ups ));
171174 if (upscli_upserror (ups ) == UPSCLI_ERR_UNKCOMMAND ) {
172175 msg = "upsd is too old to support this query" ;
173176 } else {
@@ -177,14 +180,14 @@ static void list_vars(void)
177180
178181 if (output_json ) {
179182 if (msg_is_simple ) {
180- printf (" \"error\": \"%s\"\n}\n" , msg );
183+ printf (" \"error\": \"%s\"\n}\n" , NUT_STRARG ( msg ) );
181184 } else {
182185 printf (" \"error\": \"" );
183186 json_print_esc (msg );
184187 printf ("\"\n}\n" );
185188 }
186189 }
187- fatalx (EXIT_FAILURE , "Error: %s" , msg );
190+ fatalx (EXIT_FAILURE , "Error: %s" , NUT_STRARG ( msg ) );
188191 }
189192
190193 while (upscli_list_next (ups , numq , query , & numa , & answer ) == 1 ) {
@@ -237,6 +240,8 @@ static void list_upses(int verbose)
237240 int msg_is_simple = 1 ;
238241
239242 /* check for an old upsd */
243+ upsdebugx (1 , "%s: got code %d, upserror %d" ,
244+ __func__ , ret , upscli_upserror (ups ));
240245 if (upscli_upserror (ups ) == UPSCLI_ERR_UNKCOMMAND ) {
241246 msg = "upsd is too old to support this query" ;
242247 } else {
@@ -394,6 +399,7 @@ int main(int argc, char **argv)
394399 s = getenv ("NUT_DEBUG_LEVEL" );
395400 if (s && str_to_int (s , & i , 10 ) && i > 0 ) {
396401 nut_debug_level = i ;
402+ upscli_set_debug_level (nut_debug_level );
397403 }
398404 upsdebugx (1 , "Starting NUT client: %s" , prog );
399405
0 commit comments