diff options
author | Nicolas Williams <nico@cryptonector.com> | 2014-12-30 13:13:30 -0600 |
---|---|---|
committer | Nicolas Williams <nico@cryptonector.com> | 2014-12-31 20:09:53 -0600 |
commit | ae7f8d6ab9d29bd72f462fdafa4d7a9270706d3b (patch) | |
tree | 3be6c09d87619b65f87e13e4bee4cdf24b064639 /main.c | |
parent | 7dc34b92aff7a38e16c0ef608238d03e1ac3d213 (diff) |
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.
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 22 |
1 files changed, 5 insertions, 17 deletions
@@ -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); |