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

write in the same file of input #46

Open
m47730 opened this issue Sep 3, 2024 · 2 comments
Open

write in the same file of input #46

m47730 opened this issue Sep 3, 2024 · 2 comments

Comments

@m47730
Copy link

m47730 commented Sep 3, 2024

Hi,
i like your work to create a more modern envsubst combined with statically compiling with musl, it's a very portable and efficient solution.

I have a minor request: is it possible to implement write the output in the same file as input? (without using some other tool like sponge)

ex:

cat test.txt
test: it $TEST

export TEST=work
renvsubst --variable=TEST --input=test.txt --output=test.txt
file test.txt
  test.txt: empty

if the output file is different, it works perfectly:

renvsubst --variable=TEST --input=test.txt --output=test2.txt
cat test2.txt
test: it work
@gi8lino
Copy link
Member

gi8lino commented Sep 3, 2024

hi @m47730

I like your idea! I’ll try to add a flag for this.

In the meantime, you can use something like this:

cat test.txt
test: it $TEST

export TEST=work
cat test.txt | ./renvsubst | tee test.txt
file test.txt
  test.txt: test: it work

It is ugly, but working.

@m47730
Copy link
Author

m47730 commented Sep 5, 2024

great to hear it!

I used your solution in the meantime, i ended up on something like:

# substitute variables in the same file of input
./renvsubst --variable TEST --input test.txt | tee test.txt 1>/dev/null

Thank you

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

No branches or pull requests

2 participants