Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement _experimental_snapshot/2 #3165

Closed
wants to merge 1 commit into from

Conversation

myaaaaaaaaa
Copy link
Contributor

@myaaaaaaaaa myaaaaaaaaa commented Aug 25, 2024

Enables writing to files from within jq scripts.

Resolves #3153

The scary name and lack of documentation should serve to inform users that its behavior is subject to breaking changes, and should therefore not be used in production scripts for the time being.

At the moment, this builtin performs a dry run by default. To actually write any data to disk, set the environment variable JQ_ENABLE_SNAPSHOT=1. A proper sandboxing interface is outside the scope of this PR, please refer to the link below instead:

I've renamed this builtin to snapshot/2 to highlight the fact that script execution is unaffected by the results of the file writing process (dry run, success, failure), allowing scripts that use it to remain constant and repeatable.

This allows the language to maintain referential transparency even when interacting with the outside world.

@myaaaaaaaaa myaaaaaaaaa marked this pull request as ready for review August 25, 2024 17:16
@myaaaaaaaaa myaaaaaaaaa changed the title Implement _experimental_output/2 Implement _experimental_snapshot/2 Aug 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add builtin to output to file
1 participant