Closed vincent-hugot closed 7 months ago
Actually, I see in the history that there used to be another C program called envsave, which was replaced by a simple call to env -0... so this is just the drop of the other shoe :)
https://github.com/jcnils/protonhax/commit/3f62d41048fd9944f994f6fc99b2b57c97c17a17
Hi @vincent-hugot thanks for the report, sorry it took so long to reply.
Bash only would be great and make things so simple. - it also helps me close another issue. https://github.com/jcnils/protonhax/issues/12
I will give it a try this week, but if you already have a fork working, feel free to open a PR.
Thank you!
Hi!
No, I don't have a PR ready for you, but here is a proof-of-concept:
env_save () {
export x="test test\nline\nin subshell"
declare -px > dump
}
env_load () {
export x="erased in current shell"
(source dump && echo -e $x > outsub)
cat outsub
echo -e $x
}
source envload.sh ; env_save ; env_load
restores x in the subshell (and only there) as expected.
Cheers, V
That is beautiful! Thank you so much.
I will try to get it working this week.
Thank you very much for the suggestion. It worked with just a few small changes.
Hello,
Thanks for protonhax. It's neat.
Couldn't envload.c be entirely replaced by two lines of pure bash using declare?
This handles special characters, such as line feeds, correctly: e.g. output: