fix: find and source ~/.jq file on windows (fixes #3104) (#3114)

This commit is contained in:
Kirk McKelvey authored and GitHub committed 2024-08-24 08:44:08 +09:00
1 parent da2a0b970c
commit 6322b99252
4 files changed
+20 -6

No files matched your search

+6 -4
View File
@@ -420,14 +420,16 @@ int load_program(jq_state *jq, struct locfile* src, block *out_block) {
return 1;
}
char* home = getenv("HOME");
if (home) { // silently ignore no $HOME
/* Import ~/.jq as a library named "" found in $HOME */
jv home = get_home();
if (jv_is_valid(home)) {
/* Import ~/.jq as a library named "" found in $HOME or %USERPROFILE% */
block import = gen_import_meta(gen_import("", NULL, 0),
gen_const(JV_OBJECT(
jv_string("optional"), jv_true(),
jv_string("search"), jv_string(home))));
jv_string("search"), home)));
program = BLOCK(import, program);
} else { // silently ignore if home dir not determined
jv_free(home);
}
nerrors = process_dependencies(jq, jq_get_jq_origin(jq), jq_get_prog_origin(jq), &program, &lib_state);