@port-labs/jq-node-bindings 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/binding.gyp +3 -3
- package/configure +8 -6
- package/deps/jq/.travis.yml +184 -35
- package/deps/jq/AUTHORS +31 -30
- package/deps/jq/COPYING +2 -2
- package/deps/jq/KEYS +8 -0
- package/deps/jq/Makefile.am +85 -70
- package/deps/jq/NEWS +5 -4
- package/deps/jq/README.md +18 -9
- package/deps/jq/appveyor.yml +53 -0
- package/deps/jq/compile-ios.sh +5 -5
- package/deps/jq/config/m4/check-math-func.m4 +7 -2
- package/deps/jq/configure.ac +130 -68
- package/deps/jq/docs/Rakefile +14 -135
- package/deps/jq/docs/Rakefile.manual +49 -0
- package/deps/jq/docs/Rakefile.website +76 -0
- package/deps/jq/docs/content/2.download/default.yml +115 -39
- package/deps/jq/docs/content/3.manual/manual.yml +641 -231
- package/deps/jq/docs/content/3.manual/v1.3/manual.yml +130 -130
- package/deps/jq/docs/content/3.manual/v1.4/manual.yml +160 -160
- package/deps/jq/docs/content/3.manual/v1.5/manual.yml +2878 -0
- package/deps/jq/docs/content/3.manual/v1.6/manual.yml +3287 -0
- package/deps/jq/docs/content/index/index.yml +28 -6
- package/deps/jq/docs/public/.htaccess +2 -2
- package/deps/jq/docs/public/css/base.scss +141 -59
- package/deps/jq/docs/public/js/manual-search.js +52 -0
- package/deps/jq/docs/site.yml +1 -10
- package/deps/jq/docs/templates/default.liquid +10 -10
- package/deps/jq/docs/templates/index.liquid +45 -32
- package/deps/jq/docs/templates/manual.liquid +67 -90
- package/deps/jq/docs/templates/shared/_footer.liquid +10 -5
- package/deps/jq/docs/templates/shared/_head.liquid +17 -12
- package/deps/jq/docs/templates/shared/_navbar.liquid +27 -0
- package/deps/jq/jq.1.prebuilt +523 -139
- package/deps/jq/modules/oniguruma/AUTHORS +1 -0
- package/deps/jq/modules/oniguruma/CMakeLists.txt +86 -0
- package/deps/jq/modules/oniguruma/COPYING +28 -0
- package/deps/jq/modules/oniguruma/ChangeLog +0 -0
- package/deps/jq/modules/oniguruma/HISTORY +2138 -0
- package/deps/jq/modules/oniguruma/Makefile.am +33 -0
- package/deps/jq/modules/oniguruma/NEWS +0 -0
- package/deps/jq/modules/oniguruma/README +189 -0
- package/deps/jq/modules/oniguruma/README.ja +195 -0
- package/deps/jq/modules/oniguruma/README.md +203 -0
- package/deps/jq/modules/oniguruma/cmake/dist.cmake +321 -0
- package/deps/jq/modules/oniguruma/compile +348 -0
- package/deps/jq/modules/oniguruma/config.guess +1754 -0
- package/deps/jq/modules/oniguruma/config.sub +1890 -0
- package/deps/jq/modules/oniguruma/configure.ac +87 -0
- package/deps/jq/modules/oniguruma/contributed/libfuzzer-onig.cpp +31 -0
- package/deps/jq/modules/oniguruma/depcomp +791 -0
- package/deps/jq/modules/oniguruma/dist.info +10 -0
- package/deps/jq/modules/oniguruma/doc/API +660 -0
- package/deps/jq/modules/oniguruma/doc/API.ja +667 -0
- package/deps/jq/modules/oniguruma/doc/FAQ +12 -0
- package/deps/jq/modules/oniguruma/doc/FAQ.ja +22 -0
- package/deps/jq/modules/oniguruma/doc/RE +436 -0
- package/deps/jq/modules/oniguruma/doc/RE.ja +448 -0
- package/deps/jq/modules/oniguruma/doc/UNICODE_PROPERTIES +698 -0
- package/deps/jq/modules/oniguruma/index.html +181 -0
- package/deps/jq/modules/oniguruma/index_ja.html +184 -0
- package/deps/jq/modules/oniguruma/install-sh +541 -0
- package/deps/jq/modules/oniguruma/m4/.whatever +0 -0
- package/deps/jq/modules/oniguruma/make_win32.bat +3 -0
- package/deps/jq/modules/oniguruma/make_win64.bat +3 -0
- package/deps/jq/modules/oniguruma/missing +215 -0
- package/deps/jq/modules/oniguruma/onig-config.in +78 -0
- package/deps/jq/modules/oniguruma/oniguruma.pc.cmake.in +13 -0
- package/deps/jq/modules/oniguruma/oniguruma.pc.in +14 -0
- package/deps/jq/modules/oniguruma/sample/CMakeLists.txt +28 -0
- package/deps/jq/modules/oniguruma/sample/Makefile.am +34 -0
- package/deps/jq/modules/oniguruma/sample/bug_fix.c +131 -0
- package/deps/jq/modules/oniguruma/sample/crnl.c +127 -0
- package/deps/jq/modules/oniguruma/sample/encode.c +308 -0
- package/deps/jq/modules/oniguruma/sample/listcap.c +110 -0
- package/deps/jq/modules/oniguruma/sample/names.c +75 -0
- package/deps/jq/modules/oniguruma/sample/posix.c +96 -0
- package/deps/jq/modules/oniguruma/sample/scan.c +88 -0
- package/deps/jq/modules/oniguruma/sample/simple.c +59 -0
- package/deps/jq/modules/oniguruma/sample/sql.c +76 -0
- package/deps/jq/modules/oniguruma/sample/syntax.c +76 -0
- package/deps/jq/modules/oniguruma/sample/user_property.c +87 -0
- package/deps/jq/modules/oniguruma/src/Makefile.am +58 -0
- package/deps/jq/modules/oniguruma/src/Makefile.windows +183 -0
- package/deps/jq/modules/oniguruma/src/ascii.c +61 -0
- package/deps/jq/modules/oniguruma/src/big5.c +190 -0
- package/deps/jq/modules/oniguruma/src/config.h.cmake.in +71 -0
- package/deps/jq/modules/oniguruma/src/config.h.win32 +84 -0
- package/deps/jq/modules/oniguruma/src/config.h.win64 +84 -0
- package/deps/jq/modules/oniguruma/src/cp1251.c +203 -0
- package/deps/jq/modules/oniguruma/src/euc_jp.c +310 -0
- package/deps/jq/modules/oniguruma/src/euc_jp_prop.c +158 -0
- package/deps/jq/modules/oniguruma/src/euc_jp_prop.gperf +27 -0
- package/deps/jq/modules/oniguruma/src/euc_kr.c +188 -0
- package/deps/jq/modules/oniguruma/src/euc_tw.c +171 -0
- package/deps/jq/modules/oniguruma/src/gb18030.c +538 -0
- package/deps/jq/modules/oniguruma/src/gperf_fold_key_conv.py +67 -0
- package/deps/jq/modules/oniguruma/src/gperf_unfold_key_conv.py +55 -0
- package/deps/jq/modules/oniguruma/src/iso8859_1.c +275 -0
- package/deps/jq/modules/oniguruma/src/iso8859_10.c +242 -0
- package/deps/jq/modules/oniguruma/src/iso8859_11.c +99 -0
- package/deps/jq/modules/oniguruma/src/iso8859_13.c +231 -0
- package/deps/jq/modules/oniguruma/src/iso8859_14.c +244 -0
- package/deps/jq/modules/oniguruma/src/iso8859_15.c +238 -0
- package/deps/jq/modules/oniguruma/src/iso8859_16.c +240 -0
- package/deps/jq/modules/oniguruma/src/iso8859_2.c +238 -0
- package/deps/jq/modules/oniguruma/src/iso8859_3.c +238 -0
- package/deps/jq/modules/oniguruma/src/iso8859_4.c +240 -0
- package/deps/jq/modules/oniguruma/src/iso8859_5.c +229 -0
- package/deps/jq/modules/oniguruma/src/iso8859_6.c +99 -0
- package/deps/jq/modules/oniguruma/src/iso8859_7.c +225 -0
- package/deps/jq/modules/oniguruma/src/iso8859_8.c +99 -0
- package/deps/jq/modules/oniguruma/src/iso8859_9.c +231 -0
- package/deps/jq/modules/oniguruma/src/koi8.c +253 -0
- package/deps/jq/modules/oniguruma/src/koi8_r.c +215 -0
- package/deps/jq/modules/oniguruma/src/make_unicode_fold.sh +22 -0
- package/deps/jq/modules/oniguruma/src/make_unicode_fold_data.py +306 -0
- package/deps/jq/modules/oniguruma/src/make_unicode_property.sh +18 -0
- package/deps/jq/modules/oniguruma/src/make_unicode_property_data.py +545 -0
- package/deps/jq/modules/oniguruma/src/mktable.c +1184 -0
- package/deps/jq/modules/oniguruma/src/onig_init.c +45 -0
- package/deps/jq/modules/oniguruma/src/oniggnu.h +85 -0
- package/deps/jq/modules/oniguruma/src/onigposix.h +169 -0
- package/deps/jq/modules/oniguruma/src/oniguruma.h +841 -0
- package/deps/jq/modules/oniguruma/src/regcomp.c +6300 -0
- package/deps/jq/modules/oniguruma/src/regenc.c +917 -0
- package/deps/jq/modules/oniguruma/src/regenc.h +243 -0
- package/deps/jq/modules/oniguruma/src/regerror.c +393 -0
- package/deps/jq/modules/oniguruma/src/regexec.c +3856 -0
- package/deps/jq/modules/oniguruma/src/regext.c +202 -0
- package/deps/jq/modules/oniguruma/src/reggnu.c +147 -0
- package/deps/jq/modules/oniguruma/src/regint.h +779 -0
- package/deps/jq/modules/oniguruma/src/regparse.c +5403 -0
- package/deps/jq/modules/oniguruma/src/regparse.h +351 -0
- package/deps/jq/modules/oniguruma/src/regposerr.c +105 -0
- package/deps/jq/modules/oniguruma/src/regposix.c +306 -0
- package/deps/jq/modules/oniguruma/src/regsyntax.c +315 -0
- package/deps/jq/modules/oniguruma/src/regtrav.c +76 -0
- package/deps/jq/modules/oniguruma/src/regversion.c +57 -0
- package/deps/jq/modules/oniguruma/src/sjis.c +341 -0
- package/deps/jq/modules/oniguruma/src/sjis_prop.c +158 -0
- package/deps/jq/modules/oniguruma/src/sjis_prop.gperf +27 -0
- package/deps/jq/modules/oniguruma/src/st.c +589 -0
- package/deps/jq/modules/oniguruma/src/st.h +68 -0
- package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_fold1_key.c +2250 -0
- package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_fold2_key.c +203 -0
- package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_fold3_key.c +113 -0
- package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_fold_data.c +1225 -0
- package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_property_data.c +24742 -0
- package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_property_data_posix.c +4846 -0
- package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_unfold_key.c +2571 -0
- package/deps/jq/modules/oniguruma/src/unicode.c +664 -0
- package/deps/jq/modules/oniguruma/src/unicode_fold1_key.c +2548 -0
- package/deps/jq/modules/oniguruma/src/unicode_fold2_key.c +203 -0
- package/deps/jq/modules/oniguruma/src/unicode_fold3_key.c +113 -0
- package/deps/jq/modules/oniguruma/src/unicode_fold_data.c +1366 -0
- package/deps/jq/modules/oniguruma/src/unicode_property_data.c +25306 -0
- package/deps/jq/modules/oniguruma/src/unicode_property_data_posix.c +4940 -0
- package/deps/jq/modules/oniguruma/src/unicode_unfold_key.c +2854 -0
- package/deps/jq/modules/oniguruma/src/utf16_be.c +235 -0
- package/deps/jq/modules/oniguruma/src/utf16_le.c +245 -0
- package/deps/jq/modules/oniguruma/src/utf32_be.c +194 -0
- package/deps/jq/modules/oniguruma/src/utf32_le.c +194 -0
- package/deps/jq/modules/oniguruma/src/utf8.c +335 -0
- package/deps/jq/modules/oniguruma/test/Makefile.am +28 -0
- package/deps/jq/modules/oniguruma/test/testc.c +874 -0
- package/deps/jq/modules/oniguruma/test/testu.c +916 -0
- package/deps/jq/modules/oniguruma/test-driver +153 -0
- package/deps/jq/modules/oniguruma/windows/testc.c +869 -0
- package/deps/jq/scripts/crosscompile +2 -1
- package/deps/jq/scripts/gen_utf8_tables.py +2 -3
- package/deps/jq/scripts/update-website +29 -0
- package/deps/jq/scripts/version +7 -2
- package/deps/jq/sig/jq-release.key +41 -0
- package/deps/jq/sig/v1.3/jq-linux-x86.asc +17 -0
- package/deps/jq/sig/v1.3/jq-linux-x86_64.asc +17 -0
- package/deps/jq/sig/v1.3/jq-osx-x86.asc +17 -0
- package/deps/jq/sig/v1.3/jq-osx-x86_64.asc +17 -0
- package/deps/jq/sig/v1.3/jq-win32.exe.asc +17 -0
- package/deps/jq/sig/v1.3/jq-win64.exe.asc +17 -0
- package/deps/jq/sig/v1.3/sha256sum.txt +6 -0
- package/deps/jq/sig/v1.4/jq-linux-x86.asc +17 -0
- package/deps/jq/sig/v1.4/jq-linux-x86_64.asc +17 -0
- package/deps/jq/sig/v1.4/jq-osx-x86.asc +17 -0
- package/deps/jq/sig/v1.4/jq-osx-x86_64.asc +17 -0
- package/deps/jq/sig/v1.4/jq-solaris11-32.asc +17 -0
- package/deps/jq/sig/v1.4/jq-solaris11-64.asc +17 -0
- package/deps/jq/sig/v1.4/jq-win32.exe.asc +17 -0
- package/deps/jq/sig/v1.4/jq-win64.exe.asc +17 -0
- package/deps/jq/sig/v1.4/sha256sum.txt +8 -0
- package/deps/jq/sig/v1.5/jq-linux32-no-oniguruma.asc +17 -0
- package/deps/jq/sig/v1.5/jq-linux32.asc +17 -0
- package/deps/jq/sig/v1.5/jq-linux64.asc +17 -0
- package/deps/jq/sig/v1.5/jq-osx-amd64.asc +17 -0
- package/deps/jq/sig/v1.5/jq-win32.exe.asc +17 -0
- package/deps/jq/sig/v1.5/jq-win64.exe.asc +17 -0
- package/deps/jq/sig/v1.5/sha256sum.txt +5 -0
- package/deps/jq/sig/v1.5rc1/jq-linux-x86_64-static.asc +17 -0
- package/deps/jq/sig/v1.5rc1/jq-win32.exe.asc +17 -0
- package/deps/jq/sig/v1.5rc1/jq-win64.exe.asc +17 -0
- package/deps/jq/sig/v1.5rc1/sha256sum.txt +3 -0
- package/deps/jq/sig/v1.5rc2/jq-linux-x86.asc +17 -0
- package/deps/jq/sig/v1.5rc2/jq-linux-x86_64.asc +17 -0
- package/deps/jq/sig/v1.5rc2/jq-osx-x86_64.asc +17 -0
- package/deps/jq/sig/v1.5rc2/jq-win32.exe.asc +17 -0
- package/deps/jq/sig/v1.5rc2/jq-win64.exe.asc +17 -0
- package/deps/jq/sig/v1.5rc2/sha256sum.txt +5 -0
- package/deps/jq/sig/v1.6/jq-linux32.asc +16 -0
- package/deps/jq/sig/v1.6/jq-linux64.asc +16 -0
- package/deps/jq/sig/v1.6/jq-osx-amd64.asc +16 -0
- package/deps/jq/sig/v1.6/jq-win32.exe.asc +16 -0
- package/deps/jq/sig/v1.6/jq-win64.exe.asc +16 -0
- package/deps/jq/sig/v1.6/sha256sum.txt +5 -0
- package/deps/jq/{builtin.c → src/builtin.c} +449 -344
- package/deps/jq/{builtin.h → src/builtin.h} +0 -0
- package/deps/jq/src/builtin.jq +311 -0
- package/deps/jq/{bytecode.c → src/bytecode.c} +0 -0
- package/deps/jq/{bytecode.h → src/bytecode.h} +0 -0
- package/deps/jq/{compile.c → src/compile.c} +213 -37
- package/deps/jq/{compile.h → src/compile.h} +7 -2
- package/deps/jq/{exec_stack.h → src/exec_stack.h} +0 -0
- package/deps/jq/{execute.c → src/execute.c} +127 -24
- package/deps/jq/{inject_errors.c → src/inject_errors.c} +0 -0
- package/deps/jq/{jq.h → src/jq.h} +13 -2
- package/deps/jq/{jq_parser.h → src/jq_parser.h} +0 -0
- package/deps/jq/{jq_test.c → src/jq_test.c} +1 -1
- package/deps/jq/{jv.c → src/jv.c} +24 -5
- package/deps/jq/{jv.h → src/jv.h} +46 -11
- package/deps/jq/{jv_alloc.c → src/jv_alloc.c} +0 -0
- package/deps/jq/{jv_alloc.h → src/jv_alloc.h} +0 -0
- package/deps/jq/{jv_aux.c → src/jv_aux.c} +38 -14
- package/deps/jq/{jv_dtoa.c → src/jv_dtoa.c} +4 -5
- package/deps/jq/{jv_dtoa.h → src/jv_dtoa.h} +0 -0
- package/deps/jq/src/jv_file.c +81 -0
- package/deps/jq/{jv_parse.c → src/jv_parse.c} +8 -2
- package/deps/jq/{jv_print.c → src/jv_print.c} +80 -27
- package/deps/jq/{jv_unicode.c → src/jv_unicode.c} +28 -4
- package/deps/jq/{jv_unicode.h → src/jv_unicode.h} +1 -0
- package/deps/jq/{jv_utf8_tables.h → src/jv_utf8_tables.h} +0 -0
- package/deps/jq/{lexer.c → src/lexer.c} +317 -292
- package/deps/jq/{lexer.h → src/lexer.h} +16 -12
- package/deps/jq/{lexer.l → src/lexer.l} +5 -4
- package/deps/jq/src/libm.h +291 -0
- package/deps/jq/{linker.c → src/linker.c} +5 -3
- package/deps/jq/{linker.h → src/linker.h} +0 -0
- package/deps/jq/{locfile.c → src/locfile.c} +1 -1
- package/deps/jq/{locfile.h → src/locfile.h} +0 -0
- package/deps/jq/{main.c → src/main.c} +202 -100
- package/deps/jq/{opcode_list.h → src/opcode_list.h} +4 -0
- package/deps/jq/{parser.c → src/parser.c} +1149 -1069
- package/deps/jq/{parser.h → src/parser.h} +28 -24
- package/deps/jq/{parser.y → src/parser.y} +108 -52
- package/deps/jq/{util.c → src/util.c} +12 -9
- package/deps/jq/{util.h → src/util.h} +0 -0
- package/deps/jq/tests/base64.test +35 -0
- package/deps/jq/tests/base64test +5 -0
- package/deps/jq/tests/jq-f-test.sh +4 -0
- package/deps/jq/tests/jq.test +305 -21
- package/deps/jq/tests/jqtest +1 -1
- package/deps/jq/tests/mantest +1 -1
- package/deps/jq/tests/onig.test +13 -0
- package/deps/jq/tests/onigtest +1 -1
- package/deps/jq/tests/optional.test +20 -0
- package/deps/jq/tests/optionaltest +5 -0
- package/deps/jq/tests/setup +7 -1
- package/deps/jq/tests/shtest +133 -29
- package/deps/jq/tests/utf8-truncate.jq +3 -0
- package/deps/jq/tests/utf8test +10 -0
- package/lib/index.js +7 -1
- package/package.json +3 -3
- package/test/santiy.test.js +24 -0
- package/deps/jq/docs/default_manpage.md +0 -22
- package/deps/jq/docs/public/bootstrap/css/bootstrap-responsive.css +0 -1058
- package/deps/jq/docs/public/bootstrap/css/bootstrap-responsive.min.css +0 -9
- package/deps/jq/docs/public/bootstrap/css/bootstrap.css +0 -5224
- package/deps/jq/docs/public/bootstrap/css/bootstrap.min.css +0 -9
- package/deps/jq/docs/public/bootstrap/img/glyphicons-halflings-white.png +0 -0
- package/deps/jq/docs/public/bootstrap/img/glyphicons-halflings.png +0 -0
- package/deps/jq/docs/public/bootstrap/js/bootstrap.js +0 -2027
- package/deps/jq/docs/public/bootstrap/js/bootstrap.min.js +0 -6
- package/deps/jq/docs/templates/shared/_header.liquid +0 -26
- package/deps/jq/jq.1.default +0 -39
- package/deps/jq/jv_file.c +0 -49
- package/deps/jq/libm.h +0 -160
- package/deps/jq/setup.sh +0 -33
- package/reports/jest-port-api.xml +0 -35
|
@@ -17,12 +17,21 @@
|
|
|
17
17
|
#include <wtypes.h>
|
|
18
18
|
#endif
|
|
19
19
|
|
|
20
|
+
#if !defined(HAVE_ISATTY) && defined(HAVE__ISATTY)
|
|
21
|
+
#undef isatty
|
|
22
|
+
#define isatty _isatty
|
|
23
|
+
#endif
|
|
24
|
+
|
|
25
|
+
#if defined(HAVE_ISATTY) || defined(HAVE__ISATTY)
|
|
26
|
+
#define USE_ISATTY
|
|
27
|
+
#endif
|
|
28
|
+
|
|
20
29
|
#include "compile.h"
|
|
21
30
|
#include "jv.h"
|
|
22
31
|
#include "jq.h"
|
|
23
32
|
#include "jv_alloc.h"
|
|
24
33
|
#include "util.h"
|
|
25
|
-
#include "version.h"
|
|
34
|
+
#include "src/version.h"
|
|
26
35
|
|
|
27
36
|
int jq_testsuite(jv lib_dirs, int verbose, int argc, char* argv[]);
|
|
28
37
|
|
|
@@ -32,7 +41,7 @@ static const char* progname;
|
|
|
32
41
|
* For a longer help message we could use a better option parsing
|
|
33
42
|
* strategy, one that lets stack options.
|
|
34
43
|
*/
|
|
35
|
-
static void usage(int code) {
|
|
44
|
+
static void usage(int code, int keep_it_short) {
|
|
36
45
|
FILE *f = stderr;
|
|
37
46
|
|
|
38
47
|
if (code == 0)
|
|
@@ -40,30 +49,48 @@ static void usage(int code) {
|
|
|
40
49
|
|
|
41
50
|
int ret = fprintf(f,
|
|
42
51
|
"jq - commandline JSON processor [version %s]\n"
|
|
43
|
-
"
|
|
44
|
-
"\
|
|
45
|
-
"\
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"\
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"\
|
|
55
|
-
"\t
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
52
|
+
"\nUsage:\t%s [options] <jq filter> [file...]\n"
|
|
53
|
+
"\t%s [options] --args <jq filter> [strings...]\n"
|
|
54
|
+
"\t%s [options] --jsonargs <jq filter> [JSON_TEXTS...]\n\n"
|
|
55
|
+
"jq is a tool for processing JSON inputs, applying the given filter to\n"
|
|
56
|
+
"its JSON text inputs and producing the filter's results as JSON on\n"
|
|
57
|
+
"standard output.\n\n"
|
|
58
|
+
"The simplest filter is ., which copies jq's input to its output\n"
|
|
59
|
+
"unmodified (except for formatting, but note that IEEE754 is used\n"
|
|
60
|
+
"for number representation internally, with all that that implies).\n\n"
|
|
61
|
+
"For more advanced filters see the jq(1) manpage (\"man jq\")\n"
|
|
62
|
+
"and/or https://stedolan.github.io/jq\n\n"
|
|
63
|
+
"Example:\n\n\t$ echo '{\"foo\": 0}' | jq .\n"
|
|
64
|
+
"\t{\n\t\t\"foo\": 0\n\t}\n\n",
|
|
65
|
+
JQ_VERSION, progname, progname, progname);
|
|
66
|
+
if (keep_it_short) {
|
|
67
|
+
fprintf(f,
|
|
68
|
+
"For a listing of options, use %s --help.\n",
|
|
69
|
+
progname);
|
|
70
|
+
} else {
|
|
71
|
+
(void) fprintf(f,
|
|
72
|
+
"Some of the options include:\n"
|
|
73
|
+
" -c compact instead of pretty-printed output;\n"
|
|
74
|
+
" -n use `null` as the single input value;\n"
|
|
75
|
+
" -e set the exit status code based on the output;\n"
|
|
76
|
+
" -s read (slurp) all inputs into an array; apply filter to it;\n"
|
|
77
|
+
" -r output raw strings, not JSON texts;\n"
|
|
78
|
+
" -R read raw strings, not JSON texts;\n"
|
|
79
|
+
" -C colorize JSON;\n"
|
|
80
|
+
" -M monochrome (don't colorize JSON);\n"
|
|
81
|
+
" -S sort keys of objects on output;\n"
|
|
82
|
+
" --tab use tabs for indentation;\n"
|
|
83
|
+
" --arg a v set variable $a to value <v>;\n"
|
|
84
|
+
" --argjson a v set variable $a to JSON value <v>;\n"
|
|
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"
|
|
87
|
+
" --args remaining arguments are string arguments, not files;\n"
|
|
88
|
+
" --jsonargs remaining arguments are JSON arguments, not files;\n"
|
|
89
|
+
" -- terminates argument processing;\n\n"
|
|
90
|
+
"Named arguments are also available as $ARGS.named[], while\n"
|
|
91
|
+
"positional arguments are available as $ARGS.positional[].\n"
|
|
92
|
+
"\nSee the manpage for more options.\n");
|
|
93
|
+
}
|
|
67
94
|
exit((ret < 0 && code == 0) ? 2 : code);
|
|
68
95
|
}
|
|
69
96
|
|
|
@@ -104,27 +131,47 @@ enum {
|
|
|
104
131
|
PROVIDE_NULL = 4,
|
|
105
132
|
RAW_OUTPUT = 8,
|
|
106
133
|
ASCII_OUTPUT = 32,
|
|
107
|
-
|
|
108
|
-
|
|
134
|
+
COLOR_OUTPUT = 64,
|
|
135
|
+
NO_COLOR_OUTPUT = 128,
|
|
109
136
|
SORTED_OUTPUT = 256,
|
|
110
137
|
FROM_FILE = 512,
|
|
111
138
|
RAW_NO_LF = 1024,
|
|
112
139
|
UNBUFFERED_OUTPUT = 2048,
|
|
113
140
|
EXIT_STATUS = 4096,
|
|
114
|
-
|
|
115
|
-
|
|
141
|
+
EXIT_STATUS_EXACT = 8192,
|
|
142
|
+
SEQ = 16384,
|
|
143
|
+
RUN_TESTS = 32768,
|
|
116
144
|
/* debugging only */
|
|
117
|
-
DUMP_DISASM =
|
|
145
|
+
DUMP_DISASM = 65536,
|
|
118
146
|
};
|
|
119
147
|
static int options = 0;
|
|
120
148
|
|
|
149
|
+
static const char *skip_shebang(const char *p) {
|
|
150
|
+
if (strncmp(p, "#!", sizeof("#!") - 1) != 0)
|
|
151
|
+
return p;
|
|
152
|
+
const char *n = strchr(p, '\n');
|
|
153
|
+
if (n == NULL || n[1] != '#')
|
|
154
|
+
return p;
|
|
155
|
+
n = strchr(n + 1, '\n');
|
|
156
|
+
if (n == NULL || n[1] == '#' || n[1] == '\0' || n[-1] != '\\' || n[-2] == '\\')
|
|
157
|
+
return p;
|
|
158
|
+
n = strchr(n + 1, '\n');
|
|
159
|
+
if (n == NULL)
|
|
160
|
+
return p;
|
|
161
|
+
return n+1;
|
|
162
|
+
}
|
|
163
|
+
|
|
121
164
|
static int process(jq_state *jq, jv value, int flags, int dumpopts) {
|
|
122
165
|
int ret = 14; // No valid results && -e -> exit(4)
|
|
123
166
|
jq_start(jq, value, flags);
|
|
124
167
|
jv result;
|
|
125
168
|
while (jv_is_valid(result = jq_next(jq))) {
|
|
126
169
|
if ((options & RAW_OUTPUT) && jv_get_kind(result) == JV_KIND_STRING) {
|
|
127
|
-
|
|
170
|
+
if (options & ASCII_OUTPUT) {
|
|
171
|
+
jv_dumpf(result, stdout, JV_PRINT_ASCII);
|
|
172
|
+
} else {
|
|
173
|
+
fwrite(jv_string_value(result), 1, jv_string_length_bytes(jv_copy(result)), stdout);
|
|
174
|
+
}
|
|
128
175
|
ret = 0;
|
|
129
176
|
jv_free(result);
|
|
130
177
|
} else {
|
|
@@ -141,7 +188,29 @@ static int process(jq_state *jq, jv value, int flags, int dumpopts) {
|
|
|
141
188
|
if (options & UNBUFFERED_OUTPUT)
|
|
142
189
|
fflush(stdout);
|
|
143
190
|
}
|
|
144
|
-
if (
|
|
191
|
+
if (jq_halted(jq)) {
|
|
192
|
+
// jq program invoked `halt` or `halt_error`
|
|
193
|
+
options |= EXIT_STATUS_EXACT;
|
|
194
|
+
jv exit_code = jq_get_exit_code(jq);
|
|
195
|
+
if (!jv_is_valid(exit_code))
|
|
196
|
+
ret = 0;
|
|
197
|
+
else if (jv_get_kind(exit_code) == JV_KIND_NUMBER)
|
|
198
|
+
ret = jv_number_value(exit_code);
|
|
199
|
+
else
|
|
200
|
+
ret = 5;
|
|
201
|
+
jv_free(exit_code);
|
|
202
|
+
jv error_message = jq_get_error_message(jq);
|
|
203
|
+
if (jv_get_kind(error_message) == JV_KIND_STRING) {
|
|
204
|
+
fprintf(stderr, "%s", jv_string_value(error_message));
|
|
205
|
+
} else if (jv_get_kind(error_message) == JV_KIND_NULL) {
|
|
206
|
+
// Halt with no output
|
|
207
|
+
} else if (jv_is_valid(error_message)) {
|
|
208
|
+
error_message = jv_dump_string(jv_copy(error_message), 0);
|
|
209
|
+
fprintf(stderr, "%s\n", jv_string_value(error_message));
|
|
210
|
+
} // else no message on stderr; use --debug-trace to see a message
|
|
211
|
+
fflush(stderr);
|
|
212
|
+
jv_free(error_message);
|
|
213
|
+
} else if (jv_invalid_has_msg(jv_copy(result))) {
|
|
145
214
|
// Uncaught jq exception
|
|
146
215
|
jv msg = jv_invalid_get_msg(jv_copy(result));
|
|
147
216
|
jv input_pos = jq_util_input_get_position(jq);
|
|
@@ -174,10 +243,10 @@ int main(int argc, char* argv[]) {
|
|
|
174
243
|
int parser_flags = 0;
|
|
175
244
|
int nfiles = 0;
|
|
176
245
|
int badwrite;
|
|
177
|
-
jv
|
|
246
|
+
jv ARGS = jv_array(); /* positional arguments */
|
|
247
|
+
jv program_arguments = jv_object(); /* named arguments */
|
|
178
248
|
|
|
179
249
|
#ifdef WIN32
|
|
180
|
-
SetConsoleOutputCP(CP_UTF8);
|
|
181
250
|
fflush(stdout);
|
|
182
251
|
fflush(stderr);
|
|
183
252
|
_setmode(fileno(stdout), _O_TEXT | _O_U8TEXT);
|
|
@@ -209,21 +278,35 @@ int main(int argc, char* argv[]) {
|
|
|
209
278
|
|
|
210
279
|
jq_util_input_state *input_state = jq_util_input_init(NULL, NULL); // XXX add err_cb
|
|
211
280
|
|
|
212
|
-
int
|
|
281
|
+
int further_args_are_strings = 0;
|
|
282
|
+
int further_args_are_json = 0;
|
|
283
|
+
int args_done = 0;
|
|
213
284
|
int jq_flags = 0;
|
|
214
285
|
size_t short_opts = 0;
|
|
215
286
|
jv lib_search_paths = jv_null();
|
|
216
287
|
for (int i=1; i<argc; i++, short_opts = 0) {
|
|
217
|
-
if (
|
|
218
|
-
|
|
219
|
-
|
|
288
|
+
if (args_done) {
|
|
289
|
+
if (further_args_are_strings) {
|
|
290
|
+
ARGS = jv_array_append(ARGS, jv_string(argv[i]));
|
|
291
|
+
} else if (further_args_are_json) {
|
|
292
|
+
ARGS = jv_array_append(ARGS, jv_parse(argv[i]));
|
|
293
|
+
} else {
|
|
294
|
+
jq_util_input_add_input(input_state, argv[i]);
|
|
295
|
+
nfiles++;
|
|
296
|
+
}
|
|
220
297
|
} else if (!strcmp(argv[i], "--")) {
|
|
221
|
-
if (!program) usage(2);
|
|
222
|
-
|
|
298
|
+
if (!program) usage(2, 1);
|
|
299
|
+
args_done = 1;
|
|
223
300
|
} else if (!isoptish(argv[i])) {
|
|
224
301
|
if (program) {
|
|
225
|
-
|
|
226
|
-
|
|
302
|
+
if (further_args_are_strings) {
|
|
303
|
+
ARGS = jv_array_append(ARGS, jv_string(argv[i]));
|
|
304
|
+
} else if (further_args_are_json) {
|
|
305
|
+
ARGS = jv_array_append(ARGS, jv_parse(argv[i]));
|
|
306
|
+
} else {
|
|
307
|
+
jq_util_input_add_input(input_state, argv[i]);
|
|
308
|
+
nfiles++;
|
|
309
|
+
}
|
|
227
310
|
} else {
|
|
228
311
|
program = argv[i];
|
|
229
312
|
}
|
|
@@ -256,11 +339,11 @@ int main(int argc, char* argv[]) {
|
|
|
256
339
|
if (!short_opts) continue;
|
|
257
340
|
}
|
|
258
341
|
if (isoption(argv[i], 'C', "color-output", &short_opts)) {
|
|
259
|
-
options |=
|
|
342
|
+
options |= COLOR_OUTPUT;
|
|
260
343
|
if (!short_opts) continue;
|
|
261
344
|
}
|
|
262
345
|
if (isoption(argv[i], 'M', "monochrome-output", &short_opts)) {
|
|
263
|
-
options |=
|
|
346
|
+
options |= NO_COLOR_OUTPUT;
|
|
264
347
|
if (!short_opts) continue;
|
|
265
348
|
}
|
|
266
349
|
if (isoption(argv[i], 'a', "ascii-output", &short_opts)) {
|
|
@@ -269,7 +352,7 @@ int main(int argc, char* argv[]) {
|
|
|
269
352
|
}
|
|
270
353
|
if (isoption(argv[i], 0, "unbuffered", &short_opts)) {
|
|
271
354
|
options |= UNBUFFERED_OUTPUT;
|
|
272
|
-
|
|
355
|
+
continue;
|
|
273
356
|
}
|
|
274
357
|
if (isoption(argv[i], 'S', "sort-keys", &short_opts)) {
|
|
275
358
|
options |= SORTED_OUTPUT;
|
|
@@ -294,7 +377,7 @@ int main(int argc, char* argv[]) {
|
|
|
294
377
|
if (isoption(argv[i], 0, "tab", &short_opts)) {
|
|
295
378
|
dumpopts &= ~JV_PRINT_INDENT_FLAGS(7);
|
|
296
379
|
dumpopts |= JV_PRINT_TAB | JV_PRINT_PRETTY;
|
|
297
|
-
|
|
380
|
+
continue;
|
|
298
381
|
}
|
|
299
382
|
if (isoption(argv[i], 0, "indent", &short_opts)) {
|
|
300
383
|
if (i >= argc - 1) {
|
|
@@ -309,95 +392,108 @@ int main(int argc, char* argv[]) {
|
|
|
309
392
|
}
|
|
310
393
|
dumpopts |= JV_PRINT_INDENT_FLAGS(indent);
|
|
311
394
|
i++;
|
|
312
|
-
|
|
395
|
+
continue;
|
|
313
396
|
}
|
|
314
397
|
if (isoption(argv[i], 0, "seq", &short_opts)) {
|
|
315
398
|
options |= SEQ;
|
|
316
|
-
|
|
399
|
+
continue;
|
|
317
400
|
}
|
|
318
401
|
if (isoption(argv[i], 0, "stream", &short_opts)) {
|
|
319
402
|
parser_flags |= JV_PARSE_STREAMING;
|
|
320
|
-
|
|
403
|
+
continue;
|
|
321
404
|
}
|
|
322
405
|
if (isoption(argv[i], 0, "stream-errors", &short_opts)) {
|
|
323
406
|
parser_flags |= JV_PARSE_STREAM_ERRORS;
|
|
324
|
-
|
|
407
|
+
continue;
|
|
325
408
|
}
|
|
326
409
|
if (isoption(argv[i], 'e', "exit-status", &short_opts)) {
|
|
327
410
|
options |= EXIT_STATUS;
|
|
328
411
|
if (!short_opts) continue;
|
|
329
412
|
}
|
|
330
413
|
// FIXME: For --arg* we should check that the varname is acceptable
|
|
414
|
+
if (isoption(argv[i], 0, "args", &short_opts)) {
|
|
415
|
+
further_args_are_strings = 1;
|
|
416
|
+
further_args_are_json = 0;
|
|
417
|
+
continue;
|
|
418
|
+
}
|
|
419
|
+
if (isoption(argv[i], 0, "jsonargs", &short_opts)) {
|
|
420
|
+
further_args_are_strings = 0;
|
|
421
|
+
further_args_are_json = 1;
|
|
422
|
+
continue;
|
|
423
|
+
}
|
|
331
424
|
if (isoption(argv[i], 0, "arg", &short_opts)) {
|
|
332
425
|
if (i >= argc - 2) {
|
|
333
426
|
fprintf(stderr, "%s: --arg takes two parameters (e.g. --arg varname value)\n", progname);
|
|
334
427
|
die();
|
|
335
428
|
}
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
arg = jv_object_set(arg, jv_string("value"), jv_string(argv[i+2]));
|
|
339
|
-
program_arguments = jv_array_append(program_arguments, arg);
|
|
429
|
+
if (!jv_object_has(jv_copy(program_arguments), jv_string(argv[i+1])))
|
|
430
|
+
program_arguments = jv_object_set(program_arguments, jv_string(argv[i+1]), jv_string(argv[i+2]));
|
|
340
431
|
i += 2; // skip the next two arguments
|
|
341
|
-
|
|
432
|
+
continue;
|
|
342
433
|
}
|
|
343
434
|
if (isoption(argv[i], 0, "argjson", &short_opts)) {
|
|
344
435
|
if (i >= argc - 2) {
|
|
345
436
|
fprintf(stderr, "%s: --argjson takes two parameters (e.g. --argjson varname text)\n", progname);
|
|
346
437
|
die();
|
|
347
438
|
}
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
439
|
+
if (!jv_object_has(jv_copy(program_arguments), jv_string(argv[i+1]))) {
|
|
440
|
+
jv v = jv_parse(argv[i+2]);
|
|
441
|
+
if (!jv_is_valid(v)) {
|
|
442
|
+
fprintf(stderr, "%s: invalid JSON text passed to --argjson\n", progname);
|
|
443
|
+
die();
|
|
444
|
+
}
|
|
445
|
+
program_arguments = jv_object_set(program_arguments, jv_string(argv[i+1]), v);
|
|
352
446
|
}
|
|
353
|
-
jv arg = jv_object();
|
|
354
|
-
arg = jv_object_set(arg, jv_string("name"), jv_string(argv[i+1]));
|
|
355
|
-
arg = jv_object_set(arg, jv_string("value"), v);
|
|
356
|
-
program_arguments = jv_array_append(program_arguments, arg);
|
|
357
447
|
i += 2; // skip the next two arguments
|
|
358
|
-
|
|
448
|
+
continue;
|
|
359
449
|
}
|
|
360
450
|
if (isoption(argv[i], 0, "argfile", &short_opts) ||
|
|
451
|
+
isoption(argv[i], 0, "rawfile", &short_opts) ||
|
|
361
452
|
isoption(argv[i], 0, "slurpfile", &short_opts)) {
|
|
453
|
+
int raw = isoption(argv[i], 0, "rawfile", &short_opts);
|
|
362
454
|
const char *which;
|
|
363
455
|
if (isoption(argv[i], 0, "argfile", &short_opts))
|
|
364
456
|
which = "argfile";
|
|
457
|
+
else if (raw)
|
|
458
|
+
which = "rawfile";
|
|
365
459
|
else
|
|
366
460
|
which = "slurpfile";
|
|
367
461
|
if (i >= argc - 2) {
|
|
368
462
|
fprintf(stderr, "%s: --%s takes two parameters (e.g. --%s varname filename)\n", progname, which, which);
|
|
369
463
|
die();
|
|
370
464
|
}
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
465
|
+
if (!jv_object_has(jv_copy(program_arguments), jv_string(argv[i+1]))) {
|
|
466
|
+
jv data = jv_load_file(argv[i+2], raw);
|
|
467
|
+
if (!jv_is_valid(data)) {
|
|
468
|
+
data = jv_invalid_get_msg(data);
|
|
469
|
+
fprintf(stderr, "%s: Bad JSON in --%s %s %s: %s\n", progname, which,
|
|
470
|
+
argv[i+1], argv[i+2], jv_string_value(data));
|
|
471
|
+
jv_free(data);
|
|
472
|
+
ret = 2;
|
|
473
|
+
goto out;
|
|
474
|
+
}
|
|
475
|
+
if (strcmp(which, "argfile") == 0 &&
|
|
476
|
+
jv_get_kind(data) == JV_KIND_ARRAY && jv_array_length(jv_copy(data)) == 1)
|
|
477
|
+
data = jv_array_get(data, 0);
|
|
478
|
+
program_arguments = jv_object_set(program_arguments, jv_string(argv[i+1]), data);
|
|
382
479
|
}
|
|
383
|
-
if (isoption(argv[i], 0, "argfile", &short_opts) &&
|
|
384
|
-
jv_get_kind(data) == JV_KIND_ARRAY && jv_array_length(jv_copy(data)) == 1)
|
|
385
|
-
data = jv_array_get(data, 0);
|
|
386
|
-
arg = jv_object_set(arg, jv_string("value"), data);
|
|
387
|
-
program_arguments = jv_array_append(program_arguments, arg);
|
|
388
480
|
i += 2; // skip the next two arguments
|
|
389
|
-
|
|
481
|
+
continue;
|
|
390
482
|
}
|
|
391
483
|
if (isoption(argv[i], 0, "debug-dump-disasm", &short_opts)) {
|
|
392
484
|
options |= DUMP_DISASM;
|
|
485
|
+
continue;
|
|
486
|
+
}
|
|
487
|
+
if (isoption(argv[i], 0, "debug-trace=all", &short_opts)) {
|
|
488
|
+
jq_flags |= JQ_DEBUG_TRACE_ALL;
|
|
393
489
|
if (!short_opts) continue;
|
|
394
490
|
}
|
|
395
491
|
if (isoption(argv[i], 0, "debug-trace", &short_opts)) {
|
|
396
492
|
jq_flags |= JQ_DEBUG_TRACE;
|
|
397
|
-
|
|
493
|
+
continue;
|
|
398
494
|
}
|
|
399
495
|
if (isoption(argv[i], 'h', "help", &short_opts)) {
|
|
400
|
-
usage(0);
|
|
496
|
+
usage(0, 0);
|
|
401
497
|
if (!short_opts) continue;
|
|
402
498
|
}
|
|
403
499
|
if (isoption(argv[i], 'V', "version", &short_opts)) {
|
|
@@ -423,18 +519,23 @@ int main(int argc, char* argv[]) {
|
|
|
423
519
|
}
|
|
424
520
|
}
|
|
425
521
|
|
|
426
|
-
|
|
522
|
+
#ifdef USE_ISATTY
|
|
523
|
+
if (isatty(STDOUT_FILENO)) {
|
|
427
524
|
dumpopts |= JV_PRINT_ISATTY;
|
|
428
525
|
#ifndef WIN32
|
|
429
|
-
/* Disable
|
|
526
|
+
/* Disable color by default on Windows builds as Windows
|
|
430
527
|
terminals tend not to display it correctly */
|
|
431
|
-
dumpopts |=
|
|
528
|
+
dumpopts |= JV_PRINT_COLOR;
|
|
432
529
|
#endif
|
|
433
530
|
}
|
|
531
|
+
#endif
|
|
434
532
|
if (options & SORTED_OUTPUT) dumpopts |= JV_PRINT_SORTED;
|
|
435
533
|
if (options & ASCII_OUTPUT) dumpopts |= JV_PRINT_ASCII;
|
|
436
|
-
if (options &
|
|
437
|
-
if (options &
|
|
534
|
+
if (options & COLOR_OUTPUT) dumpopts |= JV_PRINT_COLOR;
|
|
535
|
+
if (options & NO_COLOR_OUTPUT) dumpopts &= ~JV_PRINT_COLOR;
|
|
536
|
+
|
|
537
|
+
if (getenv("JQ_COLORS") != NULL && !jq_set_colors(getenv("JQ_COLORS")))
|
|
538
|
+
fprintf(stderr, "Failed to set $JQ_COLORS\n");
|
|
438
539
|
|
|
439
540
|
if (jv_get_kind(lib_search_paths) == JV_KIND_NULL) {
|
|
440
541
|
// Default search path list
|
|
@@ -457,18 +558,12 @@ int main(int argc, char* argv[]) {
|
|
|
457
558
|
else
|
|
458
559
|
jq_set_attr(jq, jv_string("VERSION_DIR"), jv_string_fmt("%.*s-master", (int)(strchr(JQ_VERSION, '-') - JQ_VERSION), JQ_VERSION));
|
|
459
560
|
|
|
460
|
-
#
|
|
461
|
-
|
|
462
|
-
#if defined(HAVE__ISATTY) && defined(isatty)
|
|
463
|
-
#undef isatty
|
|
464
|
-
#define isatty _isatty
|
|
465
|
-
#endif
|
|
466
|
-
|
|
467
|
-
if (!program && isatty(STDOUT_FILENO) && !isatty(STDIN_FILENO))
|
|
561
|
+
#ifdef USE_ISATTY
|
|
562
|
+
if (!program && (!isatty(STDOUT_FILENO) || !isatty(STDIN_FILENO)))
|
|
468
563
|
program = ".";
|
|
469
564
|
#endif
|
|
470
565
|
|
|
471
|
-
if (!program) usage(2);
|
|
566
|
+
if (!program) usage(2, 1);
|
|
472
567
|
|
|
473
568
|
if (options & FROM_FILE) {
|
|
474
569
|
char *program_origin = strdup(program);
|
|
@@ -486,11 +581,17 @@ int main(int argc, char* argv[]) {
|
|
|
486
581
|
goto out;
|
|
487
582
|
}
|
|
488
583
|
jq_set_attr(jq, jv_string("PROGRAM_ORIGIN"), jq_realpath(jv_string(dirname(program_origin))));
|
|
489
|
-
|
|
584
|
+
ARGS = JV_OBJECT(jv_string("positional"), ARGS,
|
|
585
|
+
jv_string("named"), jv_copy(program_arguments));
|
|
586
|
+
program_arguments = jv_object_set(program_arguments, jv_string("ARGS"), jv_copy(ARGS));
|
|
587
|
+
compiled = jq_compile_args(jq, skip_shebang(jv_string_value(data)), jv_copy(program_arguments));
|
|
490
588
|
free(program_origin);
|
|
491
589
|
jv_free(data);
|
|
492
590
|
} else {
|
|
493
591
|
jq_set_attr(jq, jv_string("PROGRAM_ORIGIN"), jq_realpath(jv_string("."))); // XXX is this good?
|
|
592
|
+
ARGS = JV_OBJECT(jv_string("positional"), ARGS,
|
|
593
|
+
jv_string("named"), jv_copy(program_arguments));
|
|
594
|
+
program_arguments = jv_object_set(program_arguments, jv_string("ARGS"), jv_copy(ARGS));
|
|
494
595
|
compiled = jq_compile_args(jq, program, jv_copy(program_arguments));
|
|
495
596
|
}
|
|
496
597
|
if (!compiled){
|
|
@@ -555,12 +656,13 @@ out:
|
|
|
555
656
|
ret = 2;
|
|
556
657
|
}
|
|
557
658
|
|
|
659
|
+
jv_free(ARGS);
|
|
558
660
|
jv_free(program_arguments);
|
|
559
661
|
jq_util_input_free(&input_state);
|
|
560
662
|
jq_teardown(&jq);
|
|
561
663
|
if (ret >= 10 && (options & EXIT_STATUS))
|
|
562
664
|
return ret - 10;
|
|
563
|
-
if (ret >= 10)
|
|
665
|
+
if (ret >= 10 && !(options & EXIT_STATUS_EXACT))
|
|
564
666
|
return 0;
|
|
565
667
|
return ret;
|
|
566
668
|
}
|
|
@@ -2,6 +2,7 @@ OP(LOADK, CONSTANT, 1, 1)
|
|
|
2
2
|
OP(DUP, NONE, 1, 2)
|
|
3
3
|
OP(DUPN, NONE, 1, 2)
|
|
4
4
|
OP(DUP2, NONE, 2, 3)
|
|
5
|
+
OP(PUSHK_UNDER, CONSTANT, 1, 2)
|
|
5
6
|
OP(POP, NONE, 1, 0)
|
|
6
7
|
OP(LOADV, VARIABLE, 1, 1)
|
|
7
8
|
OP(LOADVN, VARIABLE, 1, 1)
|
|
@@ -42,3 +43,6 @@ OP(CLOSURE_PARAM_REGULAR, DEFINITION, 0, 0)
|
|
|
42
43
|
OP(DEPS, CONSTANT, 0, 0)
|
|
43
44
|
OP(MODULEMETA, CONSTANT, 0, 0)
|
|
44
45
|
OP(GENLABEL, NONE, 0, 1)
|
|
46
|
+
|
|
47
|
+
OP(DESTRUCTURE_ALT, BRANCH, 0, 0)
|
|
48
|
+
OP(STOREVN, VARIABLE, 1, 0)
|