On 09/09/2010 03:37 AM, Jim Meyering wrote:
@@ -269,7 +305,18 @@ path_prepend_()
setup_()
{
- test "$VERBOSE" = yes&& set -x
+ if test "$VERBOSE" = yes; then
+ # Test whether set -x may cause the selected shell to corrupt an
+ # application's stderr. Many do, including zsh-4.3.10 and the /bin/sh
+ # from SunOS 5.11, OpenBSD 4.7 and Irix 5.x and 6.5.
+ # If enabling verbose output this way would cause trouble, simply
+ # issue a warning and refrain.
+ if $gl_set_x_corrupts_stderr_; then
+ warn_ "using SHELL=$SHELL with 'set -x' corrupts stderr"
+ else
+ set -x
You cannot reliably depend on set -x inside a shell function affecting
the parent, no thanks to zsh:
$ bash -c 'f() { set -x; }; echo $-; f; echo $-'
hBc
+ echo hxBc
hxBc
$ zsh -c 'emulate sh; f() { set -x; }; echo $-; f; echo $-'
b
b
So for true robustness, your set -x has to be at the top level, rather
than inside a function. On the other hand, zsh passes the test of not
having noisy stderr, so zsh will never encounter that set -x condition
in the first place; and unless any other shell shares zsh's misbehavior
regarding set -x within a function, I guess this patch is okay as-is.
--
Eric Blake ebl...@redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org