jqlang / jq

Command-line JSON processor
https://jqlang.github.io/jq/
Other
30.23k stars 1.57k forks source link

source ~/.jq file on windows (fixes #3104) #3114

Closed kirkoman closed 1 month ago

kirkoman commented 4 months ago

Sourcing of ~/.jq (file) was hardwired to use the HOME environment variable, which is not defined when running in a native Windows shell (PowerShell, CMD). This change lets it check the USERPROFILE environment variable and other standard fallbacks. HOME still has priority if it is set (e.g., in MSYS2 shell).

wader commented 4 months ago

Possible to add a test for this? we have some $HOME related tests here https://github.com/jqlang/jq/blob/master/tests/shtest#L355 but not sure how messy to emulate a more normal windows env?

Otherwise code change look fine with me and thanks for looking into this!

kirkoman commented 4 months ago

Ok yeah I did see those tests and briefly puzzled over them running in an msys environment. I will see if I can get at least something simple in there exercising the USERPROFILE case.

kirkoman commented 4 months ago

Test added (after some minor flopping and twitching).

itchyny commented 1 month ago

@kirkoman Could you rebase the changes? The dev manual should be updated.

wader commented 1 month ago

Forced pushed conflict fix (felt guilty as i was the one who moved the file)

itchyny commented 1 month ago

Thanks!

kirkoman commented 1 month ago

Sorry wasn't tuned in. Thanks for the rebase and the merge!

wader commented 1 month ago

@kirkoman 🥳