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

yq --inplace changes the last file given, not the first #1193

Closed
parmentelat opened this issue Apr 22, 2022 · 4 comments
Closed

yq --inplace changes the last file given, not the first #1193

parmentelat opened this issue Apr 22, 2022 · 4 comments
Labels

Comments

@parmentelat
Copy link

the documentation in this page
https://mikefarah.gitbook.io/yq/commands/evaluate-all#examples
says that the --inplace option will change the first yaml file given

my observations show otherwise, here it's the second file, so I presume it's the last one

/tmp #
yq --version
yq (https://github.com/mikefarah/yq/) version 4.24.5
/tmp #
cat > a.yaml
a: 1
/tmp #
cat > b.yaml
b: 2
/tmp #
ls -l a.yaml b.yaml
-rw-r--r-- 1 root root 5 Apr 22 15:35 a.yaml
-rw-r--r-- 1 root root 5 Apr 22 15:35 b.yaml
/tmp #
yq ea a.yaml b.yaml
a: 1
---
b: 2
/tmp #
yq --inplace ea a.yaml b.yaml
/tmp #
ls -l a.yaml b.yaml
-rw-r--r-- 1 root root  5 Apr 22 15:35 a.yaml
-rw-r--r-- 1 root root 14 Apr 22 15:35 b.yaml
/tmp #
@mikefarah
Copy link
Owner

Yep, I can replicate this! It looks like it happens when no expression is passed in. Will fix.

@parmentelat
Copy link
Author

FTR my actual use case is with using --from-file - so here again no expression passed on the command line, maybe that's a more accurate description ?

in any case please make sure to advertise if the behaviour changes as it will then break my current code ;)

thanks !

@mikefarah
Copy link
Owner

Fixed in 4.25.1 - the first file is now updated correctly!

@parmentelat
Copy link
Author

thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants