s/cookie_file/cookie_dir/g
authorTom Adams <tom@holizz.com>
Thu, 4 Jun 2009 11:39:30 +0000 (12:39 +0100)
committerTom Adams <tom@holizz.com>
Thu, 4 Jun 2009 11:39:30 +0000 (12:39 +0100)
examples/scripts/cookies.sh

index 36f1924..4745175 100755 (executable)
 [ -f ./examples/configs/cookies               ] && file=./examples/configs/cookies #useful when developing
 [ -z "$file" ] && exit 1
 
-[ -d /usr/share/uzbl/examples/data ] && cookie_file=/usr/share/uzbl/examples/data/cookies.d
-[ -d $XDG_DATA_HOME/uzbl/          ] && cookie_file=$XDG_DATA_HOME/uzbl/cookies.d
-[ -d ./examples/data/              ] && cookie_file=./examples/data/cookies.d #useful when developing
-[ -z "$cookie_file" ] && exit 1
+[ -d /usr/share/uzbl/examples/data ] && cookie_dir=/usr/share/uzbl/examples/data/cookies.d
+[ -d $XDG_DATA_HOME/uzbl/          ] && cookie_dir=$XDG_DATA_HOME/uzbl/cookies.d
+[ -d ./examples/data/              ] && cookie_dir=./examples/data/cookies.d #useful when developing
+[ -z "$cookie_dir" ] && exit 1
 
 # if this variable is set, we will use it to inform you when and which cookies we store, and when/which we send.
 #notifier=
@@ -94,13 +94,13 @@ function parse_cookie () {
 function get_cookie () {
        path_esc=${path//\//\\/}
        search="^[^\t]*$host\t[^\t]*\t$path_esc"
-       cookie=`awk "/$search/" $cookie_file/$host.cookie 2>/dev/null | tail -n 1`
+       cookie=`awk "/$search/" $cookie_dir/$host.cookie 2>/dev/null | tail -n 1`
        if [ -z "$cookie" ]
        then
-               notify "Get_cookie: search: $search in $cookie_file/$host.cookie -> no result"
+               notify "Get_cookie: search: $search in $cookie_dir/$host.cookie -> no result"
                false
        else
-               notify "Get_cookie: search: $search in $cookie_file/$host.cookie -> result: $cookie"
+               notify "Get_cookie: search: $search in $cookie_dir/$host.cookie -> result: $cookie"
                read domain alow_read_other_subdomains path http_required expiration name value <<< "$cookie"
                cookie="$name=$value" 
                true
@@ -111,8 +111,8 @@ function save_cookie () {
        if parse_cookie
        then
                data="$field_domain\tFALSE\t$field_path\tFALSE\t$field_exp\t$field_name\t$field_value"
-               notify "save_cookie: adding $data to $cookie_file/$host.cookie"
-               echo -e "$data" >> $cookie_file/$host.cookie
+               notify "save_cookie: adding $data to $cookie_dir/$host.cookie"
+               echo -e "$data" >> $cookie_dir/$host.cookie
        else
                notify "not saving a cookie. since we don't have policies yet, parse_cookie must have returned false. this is a bug"
        fi
@@ -132,11 +132,11 @@ function match () {
 }
 
 function fetch_cookie () {
-       cookie=`cat $cookie_file/$host.cookie`
+       cookie=`cat $cookie_dir/$host.cookie`
 }
 
 function store_cookie () {
-       echo $cookie > $cookie_file/$host.cookie
+       echo $cookie > $cookie_dir/$host.cookie
 }
 
 if match TRUSTED $host