After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 695681 - gsettings bash completion put error messages
gsettings bash completion put error messages
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gsettings
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Allison Karlitskaya (desrt)
gtkdev
Depends on:
Blocks:
 
 
Reported: 2013-03-12 05:22 UTC by Jiro Matsuzawa
Modified: 2017-10-05 13:42 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch for the bug (1.50 KB, patch)
2013-03-12 05:27 UTC, Jiro Matsuzawa
committed Details | Review

Description Jiro Matsuzawa 2013-03-12 05:22:50 UTC
The gsettings completion script outputs error messages when it fails to open gschemas.compiled.
For example (in the following case, attempting completion at the position "org.gno" :
--------
$ gsettings --schemadir /invalid/dir get org.gnoCould not load schemas from /invalid/dir: Failed to open file '/invalid/dir/gschemas.compiled': open() failed: No such file or directory
Could not load schemas from /invalid/dir: Failed to open file '/invalid/dir/gschemas.compiled': open() failed: No such file or directory
--------

I believe this confuses users typing on the shell. It should be better to suppress the error messages like this.


[Steps to reproduce]
1. Type the following command on bash (without Enter or Tab):
  $ gsettings --schemadir /invalid/dir get org.gno
2. Press the Tab key on the keyboard to attempt completion
Comment 1 Jiro Matsuzawa 2013-03-12 05:27:30 UTC
Created attachment 238668 [details] [review]
Patch for the bug

I suppressed error messages of completion. Please review it.
Comment 2 Matthias Clasen 2013-03-12 10:02:30 UTC
I'm not really convinced. The error message is telling you about a mistake in your commandline, after all. Might as well get it early, rather than completing things and then learn that your command won't work after all.
Comment 3 Jiro Matsuzawa 2013-03-12 13:44:16 UTC
As you say, errors might make users aware of their mistake. But I think that shell commands, not only gsettings, should not interfere in users when they are typing. They don't expect errors will appear while typing. They don't know that the completion system internally runs gsettings. Probably they will be confused about what happened by sudden errors.
Comment 4 Jiro Matsuzawa 2013-03-12 13:54:33 UTC
In addition, some parts have already suppress errors:
gio/completion/gsettings:
 48       case "${COMP_WORDS[$(($coffset+1))]}" in
 49         set)
 50           choices="$(gsettings $schemadir list-keys ${COMP_WORDS[$(($coffset+2))]} 2> /dev/null | sed -e 's.$. .')"
 51           ;;
 52 
 53         get|range|reset|writable|monitor)
 54           choices="$(gsettings $schemadir list-keys ${COMP_WORDS[$(($coffset+2))]} 2> /dev/null)"
 55           ;;
 56       esac
 57       ;;
 58 
 59     4)
 60       case "${COMP_WORDS[$(($coffset+2))]}" in
 61         set)
 62           range=($(gsettings $schemadir range ${COMP_WORDS[$(($coffset+2))]} ${COMP_WORDS[$(($coffset+3))]} 2> /dev/null))
Comment 5 Philip Withnall 2017-10-05 13:40:24 UTC
I agree with Jiro Matsuzawa; I think it’s appropriate to squash the error messages while doing command-line completion, since it basically breaks the completion. Nobody can really be expected to change their command line on the fly as a result of an interposed error message in the completion.

I’ll push the patch.