From 3f33558e48612004b70d0b726f7e5651b6f67ea1 Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Sun, 16 May 2010 15:11:12 +0200 Subject: Avoid bash specific syntax in helpers Most of our helpers don't really depend on bash, and work just fine with every system shell. Thus, let's avoid "bashisms" in there to accomodate more bare-bone shells (like dash, see https://wiki.ubuntu.com/DashAsBinSh ) Signed-off-by: Luca Bruno --- examples/config/config | 6 +++--- examples/data/scripts/formfiller.sh | 5 +++-- examples/data/scripts/insert_bookmark.sh | 4 ++-- examples/data/scripts/instance-select-wmii.sh | 8 ++++---- 4 files changed, 12 insertions(+), 11 deletions(-) (limited to 'examples') diff --git a/examples/config/config b/examples/config/config index cff13ad..6c4b0fb 100644 --- a/examples/config/config +++ b/examples/config/config @@ -251,8 +251,8 @@ set ebind = @mode_bind global,-insert @cbind gh = uri http://www.uzbl.org # Yanking & pasting binds -@cbind yu = sh 'echo -n $6 | xclip' -@cbind yy = sh 'echo -n $7 | xclip' +@cbind yu = sh 'printf $6 | xclip' +@cbind yy = sh 'printf $7 | xclip' # Go the page from primary selection @cbind p = sh 'echo "uri `xclip -selection primary -o | sed s/\\\@/%40/g`" > $4' @@ -264,7 +264,7 @@ set ebind = @mode_bind global,-insert @bind = sh 'echo "event INJECT_KEYCMD `xclip -o | sed s/\\\@/%40/g`" > $4' # Bookmark inserting binds -@cbind b_ = sh 'echo -e "$6 %s" >> $XDG_DATA_HOME/uzbl/bookmarks' +@cbind b_ = sh 'echo `printf "$6 %s"` >> $XDG_DATA_HOME/uzbl/bookmarks' # Or use a script to insert a bookmark. @cbind B = spawn @scripts_dir/insert_bookmark.sh diff --git a/examples/data/scripts/formfiller.sh b/examples/data/scripts/formfiller.sh index 69eca17..deccea2 100755 --- a/examples/data/scripts/formfiller.sh +++ b/examples/data/scripts/formfiller.sh @@ -51,6 +51,7 @@ else fi PROMPT="Choose profile" +RAND=$(dd if=/dev/urandom count=1 2> /dev/null | cksum | cut -c 1-5) MODELINE="> vim:ft=formfiller" keydir=${XDG_DATA_HOME:-$HOME/.local/share}/uzbl/dforms @@ -159,7 +160,7 @@ then then menu=`cat $keydir/$domain| \ sed -n 's/^!profile=\([^[:blank:]]\+\)/\1/p'` - option=`echo -e -n "$menu"| dmenu ${LINES} -nb "${NB}" -nf "${NF}" -sb "${SB}" -sf "${SF}" -p "${PROMPT}"` + option=`printf "$menu"| dmenu ${LINES} -nb "${NB}" -nf "${NF}" -sb "${SB}" -sf "${SF}" -p "${PROMPT}"` fi # Remove comments @@ -210,7 +211,7 @@ else if [ "$action" = 'new' -o "$action" = 'add' ] then [ "$action" = 'new' ] && echo "$MODELINE" > $keydir/$domain - echo "!profile=NAME_THIS_PROFILE$RANDOM" >> $keydir/$domain + echo "!profile=NAME_THIS_PROFILE$RAND" >> $keydir/$domain # # 2. and 3. line (tr -d and sed) are because, on gmail login for example, # tag is splited into lines diff --git a/examples/data/scripts/insert_bookmark.sh b/examples/data/scripts/insert_bookmark.sh index d0ec84e..2ec5975 100755 --- a/examples/data/scripts/insert_bookmark.sh +++ b/examples/data/scripts/insert_bookmark.sh @@ -3,7 +3,7 @@ [ -d "${XDG_DATA_HOME:-$HOME/.local/share}/uzbl" ] || exit 1 file=${XDG_DATA_HOME:-$HOME/.local/share}/uzbl/bookmarks -which zenity &>/dev/null || exit 2 +which zenity 2>&1 >/dev/null || exit 2 url=$6 # replace tabs, they are pointless in titles and we want to use tabs as delimiter. title=$(echo "$7" | sed 's/\t/ /') @@ -14,5 +14,5 @@ url=`echo $entry | awk '{print $1}'` # TODO: check if already exists, if so, and tags are different: ask if you want to replace tags echo "$entry" >/dev/null #for some reason we need this.. don't ask me why -echo -e "$entry" >> $file +printf "$entry\n" >> $file true diff --git a/examples/data/scripts/instance-select-wmii.sh b/examples/data/scripts/instance-select-wmii.sh index fdd27e6..64b859e 100755 --- a/examples/data/scripts/instance-select-wmii.sh +++ b/examples/data/scripts/instance-select-wmii.sh @@ -20,7 +20,7 @@ else DMENU="dmenu -i" fi -if [ "$1" == 'list' ] +if [ "$1" = 'list' ] then list= # get window id's of uzbl clients. we could also get the label in one shot but it's pretty tricky @@ -29,9 +29,9 @@ then label=$(wmiir read /client/$i/label) list="$list$i : $label\n" done - window=$(echo -e "$list" | $DMENU $COLORS | cut -d ' ' -f1) + window=$(printf "$list\n" | $DMENU $COLORS | cut -d ' ' -f1) wmiir xwrite /tag/sel/ctl "select client $window" -elif [ "$1" == 'next' ] +elif [ "$1" = 'next' ] then current=$(wmiir read /client/sel/ctl | head -n 1) # find the next uzbl window and focus it @@ -40,7 +40,7 @@ then then wmiir xwrite /tag/sel/ctl "select client $next" fi -elif [ "$1" == 'prev' ] +elif [ "$1" = 'prev' ] then current=$(wmiir read /client/sel/ctl | head -n 1) prev=$(wmiir read /tag/sel/index | grep -B 10000 " $current " | tac | grep -m 1 uzbl | cut -d ' ' -f2) -- cgit v1.2.3