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

In-place substitution in files #22

Open
sanmai-NL opened this issue Sep 25, 2016 · 5 comments
Open

In-place substitution in files #22

sanmai-NL opened this issue Sep 25, 2016 · 5 comments

Comments

@sanmai-NL
Copy link

I would like to have this feature in order to simplify logic in shell scripts executing sigil. Are you considering this?

@progrium
Copy link
Contributor

Can you give a few examples of what you mean by this?

On Sun, Sep 25, 2016 at 3:36 AM, Sander Maijers [email protected]
wrote:

I would like to have this feature in order to simplify logic in shell
scripts executing sigil. Are you considering this?


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#22, or mute the thread
https://github.com/notifications/unsubscribe-auth/AAACh1-h8T8nzGhJurvWMU7Nn9MoG5CIks5qtjKpgaJpZM4KF2kW
.

Jeff Lindsay
http://progrium.com

@sanmai-NL
Copy link
Author

sanmai-NL commented Sep 26, 2016

For example, when I wish to template a config file, I may not want to require both a template of the config file and a rendered config file at a different path. In that case I may want to substitute in-place, within one file (similar to sed -i). Redirecting output to the input (template) file truncates it.

@Moulde
Copy link

Moulde commented Jan 18, 2018

This is what i'm experiencing as well.

cat src/environments/environment.prod.ts | sigil -p VERSION=tag
The above command replaces the version field in the file content, and prints the correct output to console. But if i try to output it to the same file, like so.

cat src/environments/environment.prod.ts | sigil -p VERSION=tag > src/environments/environment.prod.ts

The file is empty. This seems like it should be possible?

EDIT: This seems like it's not a sigil issue, but a bash issue instead.
https://stackoverflow.com/questions/6696842/bash-redirect-input-from-file-back-into-same-file
I hacked around this by making sigil output to tmp file, then mv the tempfile to the path of the original file.

@YarekTyshchenko
Copy link

This would be very useful. Would you accept a PR for this?

@josegonzalez
Copy link
Member

Yes we would.

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

5 participants