@@ -83,6 +83,7 @@ static void usage(int code, int keep_it_short) {
83
83
" --arg a v set variable $a to value <v>;\n"
84
84
" --argjson a v set variable $a to JSON value <v>;\n"
85
85
" --slurpfile a f set variable $a to an array of JSON texts read from <f>;\n"
86
+ " --rawfile a f set variable $a to a string consisting of the contents of <f>;\n"
86
87
" --args remaining arguments are string arguments, not files;\n"
87
88
" --jsonargs remaining arguments are JSON arguments, not files;\n"
88
89
" -- terminates argument processing;\n\n"
@@ -443,18 +444,22 @@ int main(int argc, char* argv[]) {
443
444
continue ;
444
445
}
445
446
if (isoption (argv [i ], 0 , "argfile" , & short_opts ) ||
447
+ isoption (argv [i ], 0 , "rawfile" , & short_opts ) ||
446
448
isoption (argv [i ], 0 , "slurpfile" , & short_opts )) {
449
+ int raw = isoption (argv [i ], 0 , "rawfile" , & short_opts );
447
450
const char * which ;
448
451
if (isoption (argv [i ], 0 , "argfile" , & short_opts ))
449
452
which = "argfile" ;
453
+ else if (raw )
454
+ which = "rawfile" ;
450
455
else
451
456
which = "slurpfile" ;
452
457
if (i >= argc - 2 ) {
453
458
fprintf (stderr , "%s: --%s takes two parameters (e.g. --%s varname filename)\n" , progname , which , which );
454
459
die ();
455
460
}
456
461
if (!jv_object_has (jv_copy (program_arguments ), jv_string (argv [i + 1 ]))) {
457
- jv data = jv_load_file (argv [i + 2 ], 0 );
462
+ jv data = jv_load_file (argv [i + 2 ], raw );
458
463
if (!jv_is_valid (data )) {
459
464
data = jv_invalid_get_msg (data );
460
465
fprintf (stderr , "%s: Bad JSON in --%s %s %s: %s\n" , progname , which ,
0 commit comments