John Eckersberg
2015-Aug-12 14:32 UTC
[Libguestfs] [PATCH 0/1] dib: handle unsetting functions in environment
This fixes this error I'm hitting when trying to run virt-dib: $ ./run virt-dib -v -x -B ~/git/diskimage-builder/lib/ --element-path ~/git/diskimage-builder/elements/ fedora-minimal [ 0.0] Elements: base fedora-minimal [ 0.0] Expanded elements: base dib-init-system dib-run-parts fedora-minimal install-types package-installs pkg-map redhat-common rpm-distro yum yum-minimal [ 0.0] Carried environment variables: [ 0.0] Preparing auxiliary data [ 0.2] Running: extra-data.d/10-create-pkg-map-dir /tmp/dib.hfC3qu/aux/fake-bin/sudo: line 39: unset: `BASH_FUNC_module()': not a valid identifier virt-dib: error: external command ''/tmp/dib.hfC3qu/run-part-extra.sh' '/tmp/dib.hfC3qu/aux/hooks/extra-data.d' '10-create-pkg-map-dir'' exited with error 1
John Eckersberg
2015-Aug-12 14:33 UTC
[Libguestfs] [PATCH] dib: handle unsetting functions in environment
If a function name, with its trailing parentheses, is in the environment , trying to unset it will error out with a message of "not a valid identifier". In this case, try to unset it again with the -f option which can handle the parentheses in the supplied identifier. --- dib/dib.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dib/dib.ml b/dib/dib.ml index d730527..519da51 100644 --- a/dib/dib.ml +++ b/dib/dib.ml @@ -283,7 +283,7 @@ if [ -z \"$preserve_env\" ]; then for envvar in `env | grep '^\\w' | cut -d= -f1`; do case \"$envvar\" in PATH | USER | USERNAME | HOSTNAME | TERM | LANG | HOME | SHELL | LOGNAME ) ;; - *) unset $envvar ;; + *) unset $envvar || unset -f $envvar;; esac done fi -- 2.4.3
John Eckersberg
2015-Aug-12 14:43 UTC
[Libguestfs] [PATCH v2] dib: handle unsetting functions in environment
When I turned off debug and actually looked at the normal output, this is a bit noisy... [jeckersb@baozi libguestfs]$ ./run virt-dib -B ~/git/diskimage-builder/lib/ --element-path ~/git/diskimage-builder/elements/ fedora-minimal [ 0.0] Elements: base fedora-minimal [ 0.0] Expanded elements: base dib-init-system dib-run-parts fedora-minimal install-types package-installs pkg-map redhat-common rpm-distro yum yum-minimal [ 0.0] Carried environment variables: [ 0.0] Preparing auxiliary data [ 0.2] Running: extra-data.d/10-create-pkg-map-dir /tmp/dib.dQ8W3Z/aux/fake-bin/sudo: line 39: unset: `BASH_FUNC_module()': not a valid identifier /tmp/dib.dQ8W3Z/aux/fake-bin/sudo: line 39: unset: `BASH_FUNC_scl()': not a valid identifier /tmp/dib.dQ8W3Z/aux/fake-bin/sudo: line 39: unset: `BASH_FUNC_module()': not a valid identifier /tmp/dib.dQ8W3Z/aux/fake-bin/sudo: line 39: unset: `BASH_FUNC_scl()': not a valid identifier /tmp/dib.dQ8W3Z/aux/fake-bin/sudo: line 39: unset: `BASH_FUNC_module()': not a valid identifier /tmp/dib.dQ8W3Z/aux/fake-bin/sudo: line 39: unset: `BASH_FUNC_scl()': not a valid identifier [ 0.2] Running: extra-data.d/50-store-build-settings [ 0.2] Running: extra-data.d/99-enable-install-types [ 0.2] Running: extra-data.d/99-squash-package-install [ 0.3] Running: extra-data.d/99-yum-repo-conf [ 0.3] Opening the disks ...etc... So this one instead dumps the noise into /dev/null
Pino Toscano
2015-Aug-12 14:53 UTC
Re: [Libguestfs] [PATCH] dib: handle unsetting functions in environment
On Wednesday 12 August 2015 10:33:00 John Eckersberg wrote:> If a function name, with its trailing parentheses, is in the > environment , trying to unset it will error out with a message of "not > a valid identifier". In this case, try to unset it again with the -f > option which can handle the parentheses in the supplied identifier. > --- > dib/dib.ml | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/dib/dib.ml b/dib/dib.ml > index d730527..519da51 100644 > --- a/dib/dib.ml > +++ b/dib/dib.ml > @@ -283,7 +283,7 @@ if [ -z \"$preserve_env\" ]; then > for envvar in `env | grep '^\\w' | cut -d= -f1`; do > case \"$envvar\" in > PATH | USER | USERNAME | HOSTNAME | TERM | LANG | HOME | SHELL | LOGNAME ) ;; > - *) unset $envvar ;; > + *) unset $envvar || unset -f $envvar;;The diagnosis is good, although the fix could be improved: if bash functions need to be named as "BASH_FUNC_*", I'd match on that in the switch case above, and use -f for them. Thanks, -- Pino Toscano
Possibly Parallel Threads
- Re: [PATCH] dib: handle unsetting functions in environment
- [PATCH] dib: handle unsetting functions in environment
- [PATCH v4] dib: handle unsetting functions in environment
- [PATCH 0/1] dib: handle unsetting functions in environment
- [PATCH v2] dib: handle unsetting functions in environment