#994848 xterm: "xterm -e command" should return the exit code of "command"

Package:
xterm
Source:
xterm
Description:
X terminal emulator
Submitter:
Axel Beckert
Date:
2021-09-22 20:12:05 UTC
Severity:
wishlist
Tags:
#994848#5
Date:
2021-09-21 20:52:09 UTC
From:
To:
Hi,

for test suites of tools which manipulate terminals, it would be nice if
"xterm -e command" would return the exit code of "command", e.g.

  $ xterm -e false

should exit with return code 1, but actually does exit with return code 0.

This issue might be related with https://bugs.debian.org/427798 as being
able to save the contents of the terminal would be nice in the above
mentioned use case as well.

#994848#10
Date:
2021-09-22 19:44:06 UTC
From:
To:
That would certainly be useful for automatic tests, but seems to clash
with xterm's current use of error return codes when it itself encounters
a fatal problem.  See the "ERROR MESSAGES" section in the manpage.

All the terminal emulators on my system behave the same way as xterm and
happily exit 0, even when the command specified in the -e option cannot
be found.

Cheers,
       Sven

#994848#15
Date:
2021-09-22 20:08:19 UTC
From:
To:
Hi Sven,

Sven Joachim wrote:

Indeed. Maybe a new option is then the better way to go here. My
suggestion would be "-E" similar how Perl' -e and -E work. They do the
same, but -E does more.

For my current use case I used the following workaround to transport
output and exit code:

  override_dh_auto_test:
        xvfb-run xterm -e '( dh_auto_test ; echo $$? ) | tee debian/xterm_dh_auto_test.log'
	cat debian/xterm_dh_auto_test.log
	sh -c 'exit $$(tail -1 debian/xterm_dh_auto_test.log)'

Quite hackish, but seems to work so far. (Double dollar sign due to
being Makefile syntax.)

Only downside so far: I can't capture STDERR because as soon as I add
"2>&1", xtermcontrol argues it can't find the controlling terminal
anymore. But that might be an xtermcontrol issue.

		Regards, Axel