You are not logged in.

#1 2019-09-08 07:43:35

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 5,994
Website

weird terminal emulator bug with -e option

This is not a BL bug, but something I ran into yesterday with several of the commonly-used terminal emulators. If anyone can shed any light here or suggest what package is responsible for it, it would at least help when /if filing a Debian bug report. smile

OK when you launch any terminal emulator which supports the Debian x-terminal-emulator spec., then

<terminal> -e executable arg1 arg2...

should open a new terminal window and call "executable" with arg1 arg2 etc passed on at the end.

Unfortunately, I've found that if one of the arguments is --name=something then that whole argument is eaten up and not passed to "executable". If you pass arg1 --name arg2 then --name and arg2 are both removed from the command line, just as if they had been sent to the terminal and not to "executable". With three (I've found so far lxterminal terminator and qterminal) this happens, and qterminal does the same with --title too. roll

It's easy to test. Make a little script like this:

#!/bin/sh

for i in "$@"
do
    echo "$i"
done

sleep 2

exit

Give it a name, make it executable and call your terminal of choice to execute it like this, eg:

lxterminal -e ./test-args.sh one --name two three

What you'd expect to see is:

one
--name
two
three

But what you get is

one
three

Any other option-type argument --nam -name --namee etc etc works OK, except as I said for --title with qterminal.

Other terminals I have installed: urxvt, mate-terminal.wrapper (the standards-compliant wrapper), gnome-terminal.wrapper, xfce4-terminal.wrapper, xterm, uxterm - all these are OK.

(An easy way to run through terminals is to use

x-terminal-emulator -e ./test-args.sh one --name two

and galternatives, or 'update-alternatives' directly, to switch terminals.)

There may be other bad words - I haven't yet been through the dictionary.

If anyone can confirm this and add to the Bad Terminals or Bad Words lists it might help track down where it is coming from...

Thanks!


John
--------------------
( a boring Japan blog , Japan Links, idle twitterings  and GitStuff )
In case you forget, the rules.

Online

#2 2019-09-08 09:28:16

twoion
ほやほや
Registered: 2015-08-10
Posts: 2,534

Re: weird terminal emulator bug with -e option

I don't know about GTK-based applications but I can at least say something for Qt-based and KDE-based (=Qt-based by proxy), but for GTK it likely works similar.

The terminal emulators are GUI applications based on an object-oriented model, meaning that their window is composed from standard widgets at the base (window, menu bar, ...) and more specific widgets for specific use cases (terminal emulation widget...). Most toolkits also have at the root of any toolkit-based application a root object that handles some essential functions, for example the event loop for window events used by all widgets, but also basic application setup like parsing command line arguments, setting application style, handling GUI platform specific behaviours or canonical options, for example, X11 applications can often set their X11 window class or window name from a special command line argument. No application that is a GUI app should have to handle all these special options individually, which is why the application root object often handles these kinds of arguments before the actual application code takes over.

In Qt's case, this object is called QApplication (actually there's a hierarchy of QApplication, QGuiApplication, QCoreApplication and so on), and QApplication parses command line arguments BEFORE the application-specific argument parser sees the arguments. Application-specific options are of course implemented in the application-specific parser, and in Qt, QApplication will remove 'magic' options it has handled and pass on only the remainder to the application. Since --name and --title are likely X11-specific magic options, in your experiments, they get removed by the root application object, and the application never sees them, which is why they go missing.

So I think the documentation should list magic arguments to clear up this behaviour.

I guess the usual workaround is

# The argument to -c must be properly quoted, which
# is why this is difficult to get right.
-e /bin/bash -c 'the actual command and many more arguments including --name'

or something like that.

PS. To find all bad words, you have to dig into Qt, GTK, and possibly Enlightenment to find them smile There are a lot of 'bad' words, e.g. just starting at https://doc.qt.io/qt-5/qguiapplication.html yields a dozen. Sometimes, the applications themselves have to work around them: https://github.com/KDE/konsole/blob/mas … n.cpp#L249.


New Horizons

Offline

#3 2019-09-09 08:10:55

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 5,994
Website

Re: weird terminal emulator bug with -e option

Thanks twoion. To be honest, I'm not really looking for workarounds to what is essentially buggy behaviour (although one exists for my own particular use case).

All these terminals I tested are supposed to (according to their debian/control file) provide the Debian virtual package x-terminal-emulator, whose handling of the -e option is well defined: https://www.debian.org/doc/debian-polic … l-emulator
ie the command called after -e should be passed all the following arguments, no ifs or buts. Any exceptions, listed or not in any documentation, surely constitute a bug?

(The options listed in that Konsole code did provide some more Bad Words for qterminal, though not the gtk emulators.)

My request for help is to try to identify the package causing the bug. Since at least three emulators (one of them is the QT app qterminal) show it, while all the others don't, I don't know whether bug reports need to be filed against each one separately, or if (preferably) there is some library package causing it.

(In fact, qterminal also fails to support the -T option, so it's definitely not providing x-terminal-emulator as it claims.)

Other request is for other people to try the test script I posted above with whatever terminal emulators they have to hand and report the result. Since some terminals change their behaviour if called as x-terminal-emulator it's probably best to use the command

x-terminal-emulator -e ./test-args.sh one --name two # or other arguments to taste

and switch x-terminal-emulator using update-alternatives.


John
--------------------
( a boring Japan blog , Japan Links, idle twitterings  and GitStuff )
In case you forget, the rules.

Online

#4 2019-09-09 13:50:04

earlybird
ほやほや
Registered: 2015-12-16
Posts: 727
Website

Re: weird terminal emulator bug with -e option

johnraff wrote:

All these terminals I tested are supposed to (according to their debian/control file) provide the Debian virtual package x-terminal-emulator, whose handling of the -e option is well defined: https://www.debian.org/doc/debian-polic … l-emulator
ie the command called after -e should be passed all the following arguments, no ifs or buts. Any exceptions, listed or not in any documentation, surely constitute a bug?

Yes, these emulators do not follow the x-terminal-emulator specification.

I've just tried xterm and urxvt, both do follow the specification but they are also (!) not GTK+- or Qt-based -- this plays right into my hypothesis that generally, terminal emulators that use modern GUI toolkit like GTK and Qt are prone to violating the x-terminal-emulator spec (and have no real means to follow it due to the GUI object hierarchy inherent to these toolkits I explained earlier).

Basically, I think if you wanted to find all emulators that implement -e correctly, you probably can exclude all terminal emulators that are GTK or Qt based.

Terminal emulators that are based directly on xlib like xterm, urxvt or have custom/non-toolkit event loop implementations (such as kitty) are more likely to follow the spec.

In theory, you could try reporting the 'bad' emulators as bugs (because they are) but since these are so ubiquitous it's unlikely their Provides:x-terminal-emulator stanza will get removed (if you ask me). Maybe email a relevant Debian mailing list (like debian-devel or the general maintainer list (I forget its name)) first and look what the resonance is.

Offline

#5 2019-09-10 02:20:13

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 5,994
Website

Re: weird terminal emulator bug with -e option

earlybird wrote:

Basically, I think if you wanted to find all emulators that implement -e correctly, you probably can exclude all terminal emulators that are GTK or Qt based.

That might be a bit pessimistic. Of the reasonably popular TEs I've tested, only three - terminator, lxterminal and qterminal - fail to support -T and -e correctly. (qterminal - rather new - is the only total failure, with the other two it's just "--name".) That still leaves eg gnome-terminal, xfce4-terminal and mate-terminal which are GTK but still manage to support the spec by perl wrapper scripts, along with the non-GTK TEs you mentioned. sakura seems OK but I'm getting slightly flakey results which I don't have the time to investigate ATM.

In theory, you could try reporting the 'bad' emulators as bugs (because they are) but since these are so ubiquitous it's unlikely their Provides:x-terminal-emulator stanza will get removed (if you ask me). Maybe email a relevant Debian mailing list (like debian-devel or the general maintainer list (I forget its name)) first and look what the resonance is.

That's what I was thinking too. I might try debian-user first because I'm already following it.

Similar x-terminal-emulator support bugs have been raised and fixed (eg with terminator) in the past, so it might not be a hopeless cause.

I was originally wondering if there was some underlying library responsible for the issue, but it looks from what you say that it's more a question of individual TEs' failure to work round the toolkit complexities.


John
--------------------
( a boring Japan blog , Japan Links, idle twitterings  and GitStuff )
In case you forget, the rules.

Online

#6 2019-09-10 05:24:22

twoion
ほやほや
Registered: 2015-08-10
Posts: 2,534

Re: weird terminal emulator bug with -e option

Those Perl wrapper scripts are probably a Debian maintainer invention.


New Horizons

Offline

#7 2019-09-10 07:09:06

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 5,994
Website

Re: weird terminal emulator bug with -e option

You would have thought so, but I checked mate-terminal and mate-terminal.wrapper is in the upstream tarball. The debian postinst script sets it as an x-terminal-emulator alternative though.


John
--------------------
( a boring Japan blog , Japan Links, idle twitterings  and GitStuff )
In case you forget, the rules.

Online

Board footer

Powered by FluxBB