On Tue, Jul 26, 2022 at 09:11:24AM +0100, Richard W.M. Jones wrote:
On Tue, Jul 26, 2022 at 07:13:41AM +0200, Laszlo Ersek wrote:
> On 07/25/22 16:02, Eric Blake wrote:
> > + for (( _i = 0; _i < $_cleanup_hook_count; ++_i )); do
> > + local -n _hook=_cleanup_hook$_i
> > + "${_hook[@]}"
>
> BTW, "nameref" variables seem like a relatively new addition to bash;
> for example RHEL7 does not have them. Interestingly, the RHEL7 manual
> also does not document a nameref-like construct that *does* work in
> RHEL7, namely:
>
> $ bar=foo
> $ baz=bar
> $ echo ${!baz}
> foo
Indeed it doesn't work on RHEL 7, eg:
$ make && make -C tests check TESTS=test-eflags.sh
leaves tests/eflags.{err,out} around.
Do you have a patch for this?
This might work, although I'm not sure if the eval is safe ...
diff --git a/tests/functions.sh.in b/tests/functions.sh.in
index 82f284a..ab44128 100644
--- a/tests/functions.sh.in
+++ b/tests/functions.sh.in
@@ -88,8 +88,8 @@ _run_cleanup_hooks ()
echo $0: run cleanup hooks: exit code $_status
for (( _i = 0; _i < $_cleanup_hook_count; ++_i )); do
- local -n _hook=_cleanup_hook$_i
- "${_hook[@]}"
+ local _hook=_cleanup_hook$_i
+ eval "\${$_hook[@]}"
done
exit $_status
Rich.
[...]
> I wonder if the bash release notes mention "nameref" as a more flexible
> version of "indirect expansion"... Hm, nameref was new in bash-4.3
> <
https://lwn.net/Articles/589566/>, and RHEL7 has bash-4.2.46-35.el7_9,
> so the lack of "nameref" is understandable (not that it matters for
> upstream nbdkit :)); indirect expansion is not mentioned however as a
> similar feature.
Actually I'd like to keep things working on RHEL 7 if possible. It's
still a widely used RHEL release.
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW
_______________________________________________
Libguestfs mailing list
Libguestfs(a)redhat.com
https://listman.redhat.com/mailman/listinfo/libguestfs
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
libguestfs lets you edit virtual machines. Supports shell scripting,
bindings from many languages.
http://libguestfs.org