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 649915 - gsettings accepts unquoted strings longer than two characters
gsettings accepts unquoted strings longer than two characters
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gsettings
2.28.x
Other Linux
: Normal normal
: ---
Assigned To: Allison Karlitskaya (desrt)
gtkdev
: 650361 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2011-05-10 18:35 UTC by Andy Lutomirski
Modified: 2011-05-17 16:03 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Andy Lutomirski 2011-05-10 18:35:31 UTC
$ gsettings set org.gnome.desktop.default-applications.terminal exec gnome-terminal
[works]
$ gsettings set org.gnome.desktop.default-applications.terminal exec gn
[works]
$ gsettings set org.gnome.desktop.default-applications.terminal exec g
0:expected value
$ gsettings set org.gnome.desktop.default-applications.terminal exec ''
0:expected value

This happens with every value I've tried to set.  It's annoying because I want org.gnome.desktop.default-applications.terminal exec-arg to be blank.
Comment 1 Allison Karlitskaya (desrt) 2011-05-11 14:01:44 UTC
'' is correct, but your shell is eating it.  Use "''" or \'\' to avoid that.

Just like if you actually wanted to print out two quotes, you could not type

echo ""

but would need

echo '""' or \"\"
Comment 2 Andy Lutomirski 2011-05-11 15:17:07 UTC
Bah.

You're right, sort of.  But I can't imagine this behavior is intentional and I should rephrase my bug title to "gsettings accepts all manner of crap that should be rejected with an informative error message".

$ gsettings set org.gnome.desktop.default-applications.terminal exec gna
sets gna (no quotes)

$ gsettings set org.gnome.desktop.default-applications.terminal exec "'gna'"
also sets gna (no quotes)

$ gsettings set org.gnome.desktop.default-applications.terminal exec g
fails

The manpage says:
       When setting a key, you also need specify a VALUE The format for the
       value is that of a serialized GVariant, so e.g. a string must include
       explicit quotes: "'foo'". This format is also used when printing out
       values.

So why are unquoted strings longer than two characters getting accepted?  Pages like this even recommend that usage:

https://wiki.archlinux.org/index.php/GNOME_3#Setting_the_default_terminal_via_console

I can't be the only one getting confused by this.
Comment 3 Allison Karlitskaya (desrt) 2011-05-16 23:23:57 UTC
*** Bug 650361 has been marked as a duplicate of this bug. ***
Comment 4 David Zeuthen (not reading bugmail) 2011-05-17 14:30:56 UTC
I suggest to just make gsettings(1) behave the same way gdbus(1) does - see the _g_variant_parse_me_harder() function:

 http://git.gnome.org/browse/glib/tree/gio/gdbus-tool.c?h=glib-2-28#n490
Comment 5 Allison Karlitskaya (desrt) 2011-05-17 16:03:24 UTC
commit 8148a3c396a76012da6fc2241128a2b428c818ff
Author: Ryan Lortie <desrt@desrt.ca>
Date:   Tue May 17 11:58:46 2011 -0400

    Fix gsettings tool string handling
    
    There are some bugs caused by the way that gsettings-tool currently
    attempts to help the user when they leave the quotes off of a string
    value that they are setting.
    
    Simplify the code to make it more robust and add some comments about why
    it should be done this way.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=649915