Re: Do test-path_is_{file,dir,exists} make sense anymore with -x?
- From
Jeff King <peff@peff.net>
- Date
- Mar 5, 2019, 04:58 UTC
- Message-ID
- <20190305045851.GJ19800@sigill.intra.peff.net>
- In-Reply-To
- <20190304143633.GC28939@szeder.dev>
On Mon, Mar 04, 2019 at 03:36:33PM +0100, SZEDER Gábor wrote:
Show 31 quoted lines
> On Tue, Feb 26, 2019 at 04:01:01PM -0500, Jeff King wrote:
> > > + { set +x ; } 2>/dev/null 4>/dev/null
> >
> > Ah, this is the magic. Doing:
> >
> > set +x 2>/dev/null
> >
> > will still show it, but doing the redirection in a wrapping block means
> > that it is applied before the command inside the block is run. Clever.
>
> Yeah, clever, but unfortunately (and to me suprisingly) unportable:
>
> $ ksh
> $ set -x
> $ echo foo
> + echo foo
> foo
> $ set +x
> $
>
> It doesn't show 'set +x', how convenient! :)
> However:
>
> $ set -x
> $ echo foo 2>/dev/null
> + echo foo
> + 2> /dev/null
> foo
> $ { set +x; } 2>/dev/null
> + 2> /dev/null
> $ Hmph. Good find. As you note, this is already a problem with "-x". I'm not sure if there's an easy way to fix this. We can't wrap it in a conditional function easily. I guess we could do something like:
if test "$SOMEHOW_WE_DETECT_KSH"
then
eval "set -x; run_the_test; set +x"
else
eval "set -x; run_the_test; { set +x; } 2>/dev/null"
fibut I wonder if just ignoring it is a viable option here. We're talking about debugging output from the test suite, after all. As long as the test suite still _works_ on those shells, and as long as there are no developers on ksh-primary systems who can't bear to use another $TEST_SHELL_PATH, it's really not hurting anybody. The worst case is somebody reporting a test failure on NetBSD might have a slightly more verbose "-x" output.
-Peff