GNOME Bugzilla – Bug 577713
should string options with required argument accept --other-option as argument, or issue an error?
Last modified: 2018-05-24 11:49:05 UTC
Please describe the problem: If gnome-terminal is started with any command-line option set but without a value given for that option, it can fail badly if the missing-value option is not the last option specified (see examples below). This is normally not a problem except when started with gnome-session, which then fails silently leading to no terminals opened whatsoever. This is really half of a bug, in that gnome-terminal should fail gracefully when a command-line option is missing its value, but gnome-session should also be setting the command-line options properly. I'm opening a separate bug for gnome-session. Steps to reproduce: Method 1: On the command line: gnome-terminal --title --working-directory /tmp Method 2: On the command line: gnome-terminal --title --working-directory=/tmp Actual results: Method 1: Error: Invalid argument: "/tmp" Method 2: gnome-terminal opens in the default working directory with title set to "--working-directory=/tmp" Expected results: Either method: gnome-terminal should open with a blank (or default) title and in working directory /tmp. Does this happen every time? Yes Other information: Although the gnome-terminal usage ("gnome-terminal --help") says that all options must be followed by an equal sign (e.g. --title="Some Title" --working-directory="/tmp"), gnome-terminal actually allows the equal sign to be omitted (e.g. --title "Some Title" --working-directory /tmp) and works just fine. However, because of this, if the value for an option is missing for anything except the very last option, gnome-terminal will fail to function as expected (or will fail, period) as it attempts to interpret the next option as the value for the previous option (e.g. in Method 1, gnome-terminal attempts to set the title to "--working-directory" and then treats "/tmp" as an unrecognized option; in Method 2, gnome-terminal sets the title inappropriately to the next option/value pair). If gnome-terminal allows option/value pairs to omit the equal sign, it should fail gracefully when a value is missing (i.e. recognize that the value is missing and ignore that option). Otherwise, gnome-terminal should strictly require the equal sign between option/value pairs. While this is not normally a problem for interactive sessions (people won't set empty options deliberately), this _is_ a problem when gnome-terminal is started from scripts, e.g. by gnome-session. This is a particular problem with gnome-session (see bug linked below) as gnome-terminal will then fail silently and gnome-session will fail to open any terminal windows.
See also external bug: http://bugs.centos.org/view.php?id=3469
First, 2.16 is ancient and unsupported. Please try with a recent version, i.e. at least 2.24. Doing this on 2.26, I get these results: $ gnome-terminal --title --working-directory /tmp Opens a new terminal with title "--working-directory" $ gnome-terminal --title --working-directory=/tmp Opens a new terminal with title "--working-directory=/tmp" Both of these results are entirely as expected. --title requires an argument, which will be either "--working-directory" or "--working-directory=/tmp". gnome-terminal uses GOption for argument parsing. The --title option is declared with this GOptionEntry: { "title", 't', 0, G_OPTION_ARG_CALLBACK, option_title_callback, N_("Set the terminal title"), N_("TITLE") }, Since G_OPTION_ARG_OPTIONAL_ARG is not given, the option *requires* an argument. So this is either working as expected, or a GOption problem: should GOption recognise "--title --other-option" as an error or use --other-option as the argument to --title ? Moving to glib, but probably this is NOTABUG.
Christian, Thanks for the info. One problem is that the usage text ('gnome-terminal --help') suggests that option/value pairs are required to be delineated with equal signs. This is actually not the case, and gnome-session specifically omits the equal signs when saving its RestartCommand. Of the options you suggested, I personally think that "--title --other-option" should be recognized as an error but should fail gracefully, in that the option without a value should simply be ignored. Alternatively, gnome-terminal should require the equal sign as specified in its usage text, and then hopefully a missing option will already be handled internally. The reason this arose in the first place is due to a bad interaction with gnome-session; see bug #577720.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/209.