mirror of
https://github.com/stedolan/jq.git
synced 2024-05-11 05:55:39 +00:00
Further module system revamp (fix #659)
To import a module now use: # Import module.jq file: import "relative/path/to/module" as foo; # Use the module's defs as foo::<def-name> To import a JSON file: # Read file.json: import "relative/path/to/file" as $foo; # # Use as $foo::foo Using `-L` now drops the builtin library path and appends the requested path to the empty array (or the result of an earlier `-L`). Support for the `$JQ_LIBRARY_PATH` environment variable has been removed.
This commit is contained in:
22
main.c
22
main.c
@@ -444,23 +444,11 @@ int main(int argc, char* argv[]) {
|
||||
if (options & COLOUR_OUTPUT) dumpopts |= JV_PRINT_COLOUR;
|
||||
if (options & NO_COLOUR_OUTPUT) dumpopts &= ~JV_PRINT_COLOUR;
|
||||
|
||||
char *penv = getenv("JQ_LIBRARY_PATH");
|
||||
if (penv && jv_get_kind(lib_search_paths) == JV_KIND_NULL) {
|
||||
// Use $JQ_LIBRARY_PATH
|
||||
#ifdef WIN32
|
||||
#define PATH_ENV_SEPARATOR ";"
|
||||
#else
|
||||
#define PATH_ENV_SEPARATOR ":"
|
||||
#endif
|
||||
lib_search_paths = jv_array_concat(lib_search_paths,jv_string_split(jv_string(penv),jv_string(PATH_ENV_SEPARATOR)));
|
||||
#undef PATH_ENV_SEPARATOR
|
||||
} else if (jv_get_kind(lib_search_paths) == JV_KIND_NULL) {
|
||||
// Use compiled-in default JQ_LIBRARY_PATH
|
||||
#ifdef WIN32
|
||||
lib_search_paths = JV_ARRAY(jv_string("~/.jq"), jv_string("$ORIGIN/lib"));
|
||||
#else
|
||||
lib_search_paths = JV_ARRAY(jv_string("~/.jq"), jv_string("$ORIGIN/../lib/jq"));
|
||||
#endif
|
||||
if (jv_get_kind(lib_search_paths) == JV_KIND_NULL) {
|
||||
// Default search path list
|
||||
lib_search_paths = JV_ARRAY(jv_string("~/.jq"),
|
||||
jv_string("$ORIGIN/../lib/jq"),
|
||||
jv_string("$ORIGIN/lib"));
|
||||
}
|
||||
jq_set_attr(jq, jv_string("JQ_LIBRARY_PATH"), lib_search_paths);
|
||||
|
||||
|
Reference in New Issue
Block a user