diff --git a/docs/content/3.manual/manual.yml b/docs/content/3.manual/manual.yml index bab0eba3..02ca3caa 100644 --- a/docs/content/3.manual/manual.yml +++ b/docs/content/3.manual/manual.yml @@ -174,10 +174,6 @@ sections: Like `-r` but jq won't print a newline after each output. - * `--in-place` / `-i`: - - Edit the (first) file in-place. - * `-f filename` / `--from-file filename`: Read filter from the file rather than from a command line, like diff --git a/main.c b/main.c index 77469a06..8e46b29a 100644 --- a/main.c +++ b/main.c @@ -38,7 +38,6 @@ static void usage(int code) { fprintf(f, "\t -h\t\tthis message;\n"); fprintf(f, "\t -c\t\tcompact instead of pretty-printed output;\n"); fprintf(f, "\t -n\t\tuse `null` as the single input value;\n"); - fprintf(f, "\t -i\t\tedit the [first] file in-place;\n"); fprintf(f, "\t -s\t\tread (slurp) all inputs into an array; apply filter to it;\n"); fprintf(f, "\t -r\t\toutput raw strings, not JSON texts;\n"); fprintf(f, "\t -R\t\tread raw strings, not JSON texts;\n"); @@ -94,11 +93,10 @@ enum { RAW_NO_LF = 1024, UNBUFFERED_OUTPUT = 2048, EXIT_STATUS = 4096, - IN_PLACE = 8192, - SEQ = 16384, - RUN_TESTS = 32768, + SEQ = 8192, + RUN_TESTS = 16384, /* debugging only */ - DUMP_DISASM = 65536, + DUMP_DISASM = 32768, }; static int options = 0; @@ -151,7 +149,7 @@ int main(int argc, char* argv[]) { int ret = 0; int compiled = 0; int parser_flags = 0; - char *t = NULL; + int nfiles = 0; if (argc) progname = argv[0]; @@ -171,18 +169,17 @@ int main(int argc, char* argv[]) { size_t short_opts = 0; jv program_arguments = jv_array(); jv lib_search_paths = jv_null(); - char *first_file = 0; for (int i=1; i 0 && (size_t)n < tlen); - if (mkstemp(t) == -1) { - fprintf(stderr, "Error: %s creating temporary file", strerror(errno)); - exit(3); - } - if (freopen(t, "w", stdout) == NULL) { - fprintf(stderr, "Error: %s redirecting stdout to temporary file", strerror(errno)); - exit(3); - } - } if ((options & PROVIDE_NULL) && (options & (RAW_INPUT | SLURP))) { fprintf(stderr, "%s: --null-input cannot be used with --raw-input or --slurp\n", progname); @@ -469,8 +445,9 @@ int main(int argc, char* argv[]) { // Let jq program call `debug` builtin and have that go somewhere jq_set_debug_cb(jq, debug_cb, &dumpopts); - if (first_file == 0) + if (nfiles == 0) jq_util_input_add_input(input_state, jv_string("-")); + if (options & PROVIDE_NULL) { ret = process(jq, jv_null(), jq_flags, dumpopts); } else { @@ -502,24 +479,6 @@ int main(int argc, char* argv[]) { if (ret != 0) goto out; - if ((options & IN_PLACE)) { - FILE *devnull; -#ifdef WIN32 - devnull = freopen("NUL", "w+", stdout); -#else - devnull = freopen("/dev/null", "w+", stdout); -#endif - if (devnull == NULL) { - fprintf(stderr, "Error: %s opening /dev/null\n", strerror(errno)); - exit(3); - } - assert(first_file != 0 && strcmp(first_file, "-") != 0); - if (rename(t, first_file) == -1) { - fprintf(stderr, "Error: %s renaming temporary file\n", strerror(errno)); - exit(3); - } - jv_mem_free(t); - } out: jq_util_input_free(&input_state); jq_teardown(&jq); diff --git a/tests/run b/tests/run index 3250b33a..bb7d0727 100755 --- a/tests/run +++ b/tests/run @@ -129,11 +129,6 @@ EOF printf '1\n'|./jq -ces --seq '. == [1]' >/dev/null 2> $d/out cmp $d/out $d/expected -$VALGRIND $Q ./jq -n '0, 1, 2' > $d/a -$VALGRIND $Q ./jq -n '3, 4, 5' > $d/b -$VALGRIND $Q ./jq -i '.+1' $d/a $d/b -$VALGRIND $Q ./jq -se '. == [1,2,3,4,5,6]' $d/a - ## Test streaming parser ## If we add an option to stream to the `import ... as $symbol;` directive