Web lists-archives.com

Re: Do test-path_is_{file,dir,exists} make sense anymore with -x?




On Tue, Feb 26, 2019 at 06:48:43PM +0100, Matthieu Moy wrote:

> > '-x' tracing doesn't work in all test scripts, unless it is run with a
> > Bash version already supporting BASH_XTRACEFD, i.e. v4.1 or later.
> > Notably the default Bash shipped in macOS is somewhere around v3.2.
> 
> According to http://www.tldp.org/LDP/abs/html/bashver4.html#AEN21183,
> bash 4.1 was released on May, 2010. Are you sure macOS is _that_ late?

It's not "late", it's "never". Bash 4 switched to GPLv3.

> I also tried with dash, and -x seems to work fine too (I use "works with
> dash" as a heuristic for "should word on any shell", but it doesn't
> always work).

Yes, "-x" works everywhere. The problem is scripts which capture the
stderr of subshells or functions, which then get polluted by "-x"
output. You can fix that in two ways:

  1. Use bash 4.1+, which works around that with BASH_XTRACEFD.

  2. Don't do that. Gábor fixed most such instances already, except the
     ones in t1510. That one automatically disables "-x" tracing.

So I don't know what you tried exactly, but you should be able to
successfully run with "-x" on any script. Including t1510, but you
just won't get tracing output then.

> If -x doesn't work in some setups, it may be a good reason to wait a bit
> before trashing test_path_is_*, but if it's clear enough that the vast
> majority of platforms get -x, then why not trash these wrappers indeed.

I do think it basically works everywhere these days.

-Peff