[Surfraw-commits] [SCM] surfraw - a fast unix command line interface to WWW branch, master, updated. surfraw_2-2-5_1-20-gc46924e
Ian Beckwith
ianb at erislabs.net
Sun Oct 25 15:56:16 UTC 2009
The following commit has been merged in the master branch:
commit bd8c427d11c8a19cc9d583ad8eb6dce8b5f0b454
Author: Ian Beckwith <ianb at erislabs.net>
Date: Tue Oct 20 03:40:07 2009 +0100
Implemented XDG basedir spec for local config
(http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html)
Local config is searched for in:
* $SURFRAW_conf if defined
* $XDG_CONFIG_HOME/surfraw/conf
* $HOME/.config/surfraw/conf
* $HOME/.surfraw.conf (for backwards compatibility)
Removed definition of SURFRAW_conf from global config
diff --git a/surfraw.IN b/surfraw.IN
index 2d5faea..98a5372 100644
--- a/surfraw.IN
+++ b/surfraw.IN
@@ -50,13 +50,35 @@ load_global_conf () {
. "$conf"
}
-w3_config () {
- prefix=@prefix@
- def SURFRAW_conf $HOME/.surfraw.conf
+find_config_file () {
+ base="$1"
+ if test -n "$XDG_CONFIG_HOME" && test -r "$XDG_CONFIG_HOME/surfraw/$base"; then
+ echo "$XDG_CONFIG_HOME/surfraw/$base"
+ elif test -n "$HOME" && test -r "$HOME/.config/surfraw/$base"; then
+ echo "$HOME/.config/surfraw/$base"
+ elif test -r "$HOME/.surfraw.$base"; then
+ echo "$HOME/.surfraw.$base"
+ fi
+}
+load_local_conf () {
+ local conf
+ conf=""
+ if test -n "$SURFRAW_conf" && test -r "$SURFRAW_conf"; then
+ conf="$SURFRAW_conf"
+ else
+ conf="$(find_config_file conf)"
+ fi
+ if test -n "$conf"; then
+ . $conf
+ fi
+}
+
+
+w3_config () {
load_global_conf
w3_config_hook
- test -r "$SURFRAW_conf" && . "$SURFRAW_conf"
+ load_local_conf
}
warn () {
diff --git a/surfraw.conf.IN b/surfraw.conf.IN
index e5af60c..a6a6505 100644
--- a/surfraw.conf.IN
+++ b/surfraw.conf.IN
@@ -26,9 +26,6 @@
# autoconf guessed prefix
prefix=@prefix@
-# secondary configuation file
-def SURFRAW_conf $HOME/.surfraw.conf
-
# graphical browser? defaults to yes for meatminds. text browser users can
# work it out how to change it.
defyn SURFRAW_graphical yes
--
surfraw - a fast unix command line interface to WWW
More information about the Surfraw-commits
mailing list