[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:15 UTC 2009
The following commit has been merged in the master branch:
commit 3e4591d81276fdbcd4c666b441cb42211de7841c
Author: Ian Beckwith <ianb at erislabs.net>
Date: Tue Oct 20 02:10:15 2009 +0100
Implemented XDG basedir spec for global config
(http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html)
Looks for global config file in:
* SURFRAW_global_conf if set
* surfraw/conf under each dir in (colon separated) $XDG_CONFIG_DIRS.
* @sysconfigdir@/xdg/surfraw/conf
* @sysconfigdir@/surfraw.conf (for backwards compatibility)
diff --git a/surfraw.IN b/surfraw.IN
index 22f870c..2d5faea 100644
--- a/surfraw.IN
+++ b/surfraw.IN
@@ -22,13 +22,39 @@ w3_config_hook () {
return 1
}
+load_global_conf () {
+ local conf OIFS
+ conf=""
+ # if explicitly specified
+ if test -n "$SURFRAW_global_conf" && test -r "$SURFRAW_global_conf"; then
+ conf="$SURFRAW_global_conf"
+ elif test -n "$XDG_CONFIG_DIRS"; then
+ OIFS="$IFS"
+ IFS=:
+ set $XDG_CONFIG_DIRS
+ IFS="$OIFS"
+ for i in "$@"; do
+ if test -r "$i/surfraw/conf"; then
+ conf="$i/surfraw/conf"
+ break
+ fi
+ done
+ elif test -r "@sysconfdir@/xdg/surfraw/conf"; then # XDG default
+ conf="@sysconfdir@/xdg/surfraw/conf"
+ elif test -r "@sysconfdir@/surfraw.conf"; then # old surfraw default
+ conf="@sysconfdir@/surfraw.conf"
+ fi
+ if test -z "$conf"; then
+ err "couldn't find global config in @sysconfdir@/xdg/surfraw/conf or \$XDG_CONFIG_DIRS"
+ fi
+ . "$conf"
+}
+
w3_config () {
prefix=@prefix@
- def SURFRAW_global_conf @sysconfdir@/surfraw.conf
def SURFRAW_conf $HOME/.surfraw.conf
- test -r "$SURFRAW_global_conf" || err "couldn't source SURFRAW_global_conf ($SURFRAW_global_conf)"
- . "$SURFRAW_global_conf"
+ load_global_conf
w3_config_hook
test -r "$SURFRAW_conf" && . "$SURFRAW_conf"
}
diff --git a/surfraw.conf.IN b/surfraw.conf.IN
index 642ee81..e5af60c 100644
--- a/surfraw.conf.IN
+++ b/surfraw.conf.IN
@@ -26,9 +26,6 @@
# autoconf guessed prefix
prefix=@prefix@
-# setting this here is of dubious utility
-def SURFRAW_global_conf @sysconfdir@/surfraw.conf
-
# secondary configuation file
def SURFRAW_conf $HOME/.surfraw.conf
--
surfraw - a fast unix command line interface to WWW
More information about the Surfraw-commits
mailing list