GNOME Bugzilla – Bug 649915
gsettings accepts unquoted strings longer than two characters
Last modified: 2011-05-17 16:03:24 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.
'' 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 \"\"
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.
*** Bug 650361 has been marked as a duplicate of this bug. ***
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
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