Only run KDE browser fallback when necessary
Otherwise, in some circumstances, read_kde_browser incorrectly prints the result twice.
BUG=33842
TEST=xdg-settings get default-web-browser should not output two files when kdeglobals contains a BrowserApplication[$*] entry
Review URL: http://codereview.chromium.org/3330004
git-svn-id: http://src.chromium.org/svn/trunk/deps/third_party/xdg-utils@58316 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
diff --git a/scripts/xdg-settings b/scripts/xdg-settings
index 55795a7..7fc9f26 100755
--- a/scripts/xdg-settings
+++ b/scripts/xdg-settings
@@ -522,16 +522,18 @@
read_kde_browser()
{
browser="`kreadconfig --file kdeglobals --group General --key BrowserApplication`"
- if [ "$browser" ]; then
+ if [ x"$browser" != x ]; then
echo "$browser"
+ else
+ # kreadconfig in KDE 4 may not notice Key[$*]=... localized settings, so
+ # check by hand if it didn't find anything (oddly kwriteconfig works
+ # fine though).
+ kdeglobals_dir=`kde${KDE_SESSION_VERSION}-config --path config | cut -d ':' -f 1`
+ kdeglobals="$kdeglobals_dir/kdeglobals"
+ [ ! -f "$kdeglobals" ] && return
+ # This will only take the first value if there is more than one.
+ grep '^BrowserApplication\[$[^]=]*\]=' "$kdeglobals" | head -n 1 | cut -d= -f 2-
fi
- # kreadconfig in KDE 4 may not notice Key[$*]=... localized settings, so check
- # by hand if it didn't find anything (oddly kwriteconfig works fine though).
- kdeglobals_dir=`kde${KDE_SESSION_VERSION}-config --path config | cut -d ':' -f 1`
- kdeglobals="$kdeglobals_dir/kdeglobals"
- [ ! -f "$kdeglobals" ] && return
- # This will only take the first value if there is more than one.
- grep '^BrowserApplication\[$[^]=]*\]=' "$kdeglobals" | head -n 1 | cut -d= -f 2-
}
get_browser_kde()
diff --git a/scripts/xdg-settings.in b/scripts/xdg-settings.in
index c0d4371..fb621a9 100644
--- a/scripts/xdg-settings.in
+++ b/scripts/xdg-settings.in
@@ -213,16 +213,18 @@
read_kde_browser()
{
browser="`kreadconfig --file kdeglobals --group General --key BrowserApplication`"
- if [ "$browser" ]; then
+ if [ x"$browser" != x ]; then
echo "$browser"
+ else
+ # kreadconfig in KDE 4 may not notice Key[$*]=... localized settings, so
+ # check by hand if it didn't find anything (oddly kwriteconfig works
+ # fine though).
+ kdeglobals_dir=`kde${KDE_SESSION_VERSION}-config --path config | cut -d ':' -f 1`
+ kdeglobals="$kdeglobals_dir/kdeglobals"
+ [ ! -f "$kdeglobals" ] && return
+ # This will only take the first value if there is more than one.
+ grep '^BrowserApplication\[$[^]=]*\]=' "$kdeglobals" | head -n 1 | cut -d= -f 2-
fi
- # kreadconfig in KDE 4 may not notice Key[$*]=... localized settings, so check
- # by hand if it didn't find anything (oddly kwriteconfig works fine though).
- kdeglobals_dir=`kde${KDE_SESSION_VERSION}-config --path config | cut -d ':' -f 1`
- kdeglobals="$kdeglobals_dir/kdeglobals"
- [ ! -f "$kdeglobals" ] && return
- # This will only take the first value if there is more than one.
- grep '^BrowserApplication\[$[^]=]*\]=' "$kdeglobals" | head -n 1 | cut -d= -f 2-
}
get_browser_kde()