GNOME Bugzilla – Bug 695681
gsettings bash completion put error messages
Last modified: 2017-10-05 13:42:17 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
Created attachment 238668 [details] [review] Patch for the bug I suppressed error messages of completion. Please review it.
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.
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.
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))
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.