Skip to content

Commit

Permalink
Don't rely on support for indirect expansion in the shell
Browse files Browse the repository at this point in the history
POSIX does not define the indirect expansion syntax. Moreover, if going
to the trouble of executing Perl, one may as well take full advantage of
it. Address the issue by first having the shell export the variable.
Next, have Perl perform the replacement without utilising any form of
code injection. Instead, export 'var' into Perl's environment. That
way, Perl can reference the variable name as $ENV{var} and its value as
$ENV{$ENV{var}}.

Signed-off-by: Kerin Millar <kfm@plushkava.net>
Closes: https://bugs.gentoo.org/715202
Closes: #89
Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
  • Loading branch information
Kerin Millar authored and superm1 committed Jan 4, 2021
1 parent 97b4bdc commit f01a217
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Makefile-std
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ install-data-hook:
file=$(DESTDIR)/$$i ;\
for var in $(REPLACE_VARS) ;\
do \
perl -p -i -e "s|^$$var\s*=.*|$$var=\"$${!var}\"|" $$file;\
var="$$var" perl -p -i -e 's|^\Q$$ENV{var}\E\s*=.*|$$ENV{var}="$$ENV{$$ENV{var}}"|' $$file;\
done ;\
done

Expand All @@ -48,7 +48,7 @@ install-exec-hook:
file=$(DESTDIR)/$$i ;\
for var in $(REPLACE_VARS) ;\
do \
perl -p -i -e "s|^$$var\s*=.*|$$var=\"$${!var}\"|" $$file;\
var="$$var" perl -p -i -e 's|^\Q$$ENV{var}\E\s*=.*|$$ENV{var}="$$ENV{$$ENV{var}}"|' $$file;\
done ;\
done

Expand Down
2 changes: 1 addition & 1 deletion src/python/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ src/python/_vars.py: src/python/libsmbios_c/_vars.py configure Makefile config.
cp $< $@
for var in $(REPLACE_VARS) ;\
do \
perl -p -i -e "s|^$$var\s*=.*|$$var=\"$${!var}\"|" $@;\
var="$$var" perl -p -i -e 's|^\Q$$ENV{var}\E\s*=.*|$$ENV{var}="$$ENV{$$ENV{var}}"|' $@;\
done

0 comments on commit f01a217

Please sign in to comment.