From dcf3ffda8005c73c15f5142c61ee492f14af590a Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 10 Mar 2011 22:23:36 -0500 Subject: Use print rather than printf printf chokes on $(printf "%DD") which may very well come up in an encoded URL. Avoid that with the print alias. --- examples/data/scripts/download.sh | 5 +++-- examples/data/scripts/follow.sh | 10 ++++++---- examples/data/scripts/formfiller.sh | 6 +++--- examples/data/scripts/go_input.sh | 6 ++++-- examples/data/scripts/history.sh | 2 +- examples/data/scripts/insert_bookmark.sh | 3 ++- examples/data/scripts/instance-select-wmii.sh | 5 +++-- examples/data/scripts/load_url_from_bookmarks.sh | 5 +++-- examples/data/scripts/load_url_from_history.sh | 5 +++-- examples/data/scripts/session.sh | 22 ++++++++++++---------- 10 files changed, 40 insertions(+), 29 deletions(-) (limited to 'examples') diff --git a/examples/data/scripts/download.sh b/examples/data/scripts/download.sh index 448e086..8b4761f 100755 --- a/examples/data/scripts/download.sh +++ b/examples/data/scripts/download.sh @@ -7,11 +7,12 @@ # if nothing is printed to stdout, the download will be cancelled. . "$UZBL_UTIL_DIR/uzbl-dir.sh" +. "$UZBL_UTIL_DIR/uzbl-util.sh" # the URL that is being downloaded uri="$1" -safe_uri="$( printf "$uri" | sed -e 's/\W/-/g' )" +safe_uri="$( print "$uri" | sed -e 's/\W/-/g' )" # a filename suggested by the server or based on the URL suggested_filename="${2:-$safe_uri}" @@ -24,4 +25,4 @@ content_type="$3" total_size="$4" # just save the file to the default directory with the suggested name -printf "$UZBL_DOWNLOAD_DIR/$suggested_filename\n" +print "$UZBL_DOWNLOAD_DIR/$suggested_filename\n" diff --git a/examples/data/scripts/follow.sh b/examples/data/scripts/follow.sh index b038c12..ac5c6cb 100755 --- a/examples/data/scripts/follow.sh +++ b/examples/data/scripts/follow.sh @@ -3,24 +3,26 @@ # This script is just a wrapper around follow.js that lets us change uzbl's mode # after a link is selected. +. "$UZBL_UTIL_DIR/uzbl-util.sh" + keys="$1" shift # if socat is installed then we can change Uzbl's input mode once a link is # selected; otherwise we just select a link. if ! which socat >/dev/null 2>&1; then - printf "script @scripts_dir/follow.js \"@{follow_hint_keys} $keys\"\n" > "$UZBL_FIFO" + print "script @scripts_dir/follow.js \"@{follow_hint_keys} $keys\"\n" > "$UZBL_FIFO" exit fi -result="$( printf "script @scripts_dir/follow.js \"@{follow_hint_keys} $keys\"\n" | socat - "unix-connect:$UZBL_SOCKET" )" +result="$( print "script @scripts_dir/follow.js \"@{follow_hint_keys} $keys\"\n" | socat - "unix-connect:$UZBL_SOCKET" )" case $result in *XXXEMIT_FORM_ACTIVEXXX*) # a form element was selected - printf "event FORM_ACTIVE\n" > "$UZBL_FIFO" + print "event FORM_ACTIVE\n" > "$UZBL_FIFO" ;; *XXXRESET_MODEXXX*) # a link was selected, reset uzbl's input mode - printf "set mode=\n" > "$UZBL_FIFO" + print "set mode=\n" > "$UZBL_FIFO" ;; esac diff --git a/examples/data/scripts/formfiller.sh b/examples/data/scripts/formfiller.sh index 2895e5b..17634e2 100755 --- a/examples/data/scripts/formfiller.sh +++ b/examples/data/scripts/formfiller.sh @@ -56,7 +56,7 @@ MODELINE="> vim:ft=formfiller" action="$1" shift -domain="$( printf "$UZBL_URI\n" | sed -e 's/\(http\|https\):\/\/\([^\/]\+\)\/.*/\2/' )" +domain="$( print "$UZBL_URI\n" | sed -e 's/\(http\|https\):\/\/\([^\/]\+\)\/.*/\2/' )" form_file="$UZBL_FORMS_DIR/$domain" if [ "$action" != 'edit' ] && [ "$action" != 'new' ] && [ "$action" != 'load' ] && [ "$action" != 'add' ] && [ "$action" != 'once' ]; then @@ -126,7 +126,7 @@ if [ "$action" = 'load' ]; then [ -e "$form_file" ] || exit 2 if [ "$( grep "!profile" "$form_file" | wc -l )" -gt 1 ]; then menu="$( sed -n -e 's/^!profile=\([^[:blank:]]\+\)/\1/p' "$form_file" )" - option="$( printf "$menu" | $DMENU )" + option="$( print "$menu" | $DMENU )" fi sed -i -e 's/^\([^{]\+\){\([^}]*\)}(\(radio\|checkbox\)):\(off\|no\|false\|unchecked\|0\|$\)/\1{\2}(\3):0/I;s/^\([^{]\+\){\([^}]*\)}(\(radio\|checkbox\)):[^0]\+/\1{\2}(\3):1/I' "$form_file" @@ -170,7 +170,7 @@ elif [ "$action" = "once" ]; then else if [ "$action" = 'new' -o "$action" = 'add' ]; then [ "$action" = 'new' ] && echo "$MODELINE" > "$form_file" - printf "!profile=NAME_THIS_PROFILE$RAND\n" >> "$form_file" + print "!profile=NAME_THIS_PROFILE$RAND\n" >> "$form_file" # # 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/go_input.sh b/examples/data/scripts/go_input.sh index 6574a83..ad236d1 100755 --- a/examples/data/scripts/go_input.sh +++ b/examples/data/scripts/go_input.sh @@ -1,7 +1,9 @@ #!/bin/sh -case "$( printf "script @scripts_dir/go_input.js\n" | socat - "unix-connect:$UZBL_SOCKET" )" in +. "$UZBL_UTIL_DIR/uzbl-util.sh" + +case "$( print "script @scripts_dir/go_input.js\n" | socat - "unix-connect:$UZBL_SOCKET" )" in *XXXEMIT_FORM_ACTIVEXXX*) - printf "event FORM_ACTIVE\n" > "$UZBL_FIFO" + print "event FORM_ACTIVE\n" > "$UZBL_FIFO" ;; esac diff --git a/examples/data/scripts/history.sh b/examples/data/scripts/history.sh index 4b4e970..d1e3c0f 100755 --- a/examples/data/scripts/history.sh +++ b/examples/data/scripts/history.sh @@ -4,4 +4,4 @@ >> "$UZBL_HISTORY_FILE" || exit 1 -printf "$( date +'%Y-%m-%d %H:%M:%S' ) $UZBL_URI $UZBL_TITLE\n" >> "$UZBL_HISTORY_FILE" +print "$( date +'%Y-%m-%d %H:%M:%S' ) $UZBL_URI $UZBL_TITLE\n" >> "$UZBL_HISTORY_FILE" diff --git a/examples/data/scripts/insert_bookmark.sh b/examples/data/scripts/insert_bookmark.sh index 21a2aac..5d41131 100755 --- a/examples/data/scripts/insert_bookmark.sh +++ b/examples/data/scripts/insert_bookmark.sh @@ -1,6 +1,7 @@ #!/bin/sh . "$UZBL_UTIL_DIR/uzbl-dir.sh" +. "$UZBL_UTIL_DIR/uzbl-util.sh" >> "$UZBL_BOOKMARKS_FILE" || exit 1 @@ -11,4 +12,4 @@ exitstatus="$?" [ "$exitstatus" -eq 0 ] || exit "$exitstatus" # TODO: check if already exists, if so, and tags are different: ask if you want to replace tags -printf "$UZBL_URI $tags\n" >> "$UZBL_BOOKMARKS_FILE" +print "$UZBL_URI $tags\n" >> "$UZBL_BOOKMARKS_FILE" diff --git a/examples/data/scripts/instance-select-wmii.sh b/examples/data/scripts/instance-select-wmii.sh index c12f7b7..d340dda 100755 --- a/examples/data/scripts/instance-select-wmii.sh +++ b/examples/data/scripts/instance-select-wmii.sh @@ -13,6 +13,7 @@ DMENU_SCHEME="wmii" . "$UZBL_UTIL_DIR/dmenu.sh" +. "$UZBL_UTIL_DIR/uzbl-util.sh" case "$1" in "list") @@ -22,7 +23,7 @@ case "$1" in label="$( wmiir read /client/$i/label )" list="$list$i : $label\n" done - window="$( printf "$list\n" | $DMENU | cut -d ' ' -f 1 )" + window="$( print "$list\n" | $DMENU | cut -d ' ' -f 1 )" wmiir xwrite /tag/sel/ctl "select client $window" ;; "next") @@ -41,7 +42,7 @@ case "$1" in fi ;; * ) - printf "$1 not valid\n" >&2 + print "$1 not valid\n" >&2 exit 2 ;; esac diff --git a/examples/data/scripts/load_url_from_bookmarks.sh b/examples/data/scripts/load_url_from_bookmarks.sh index d7bf104..30417f1 100755 --- a/examples/data/scripts/load_url_from_bookmarks.sh +++ b/examples/data/scripts/load_url_from_bookmarks.sh @@ -7,6 +7,7 @@ DMENU_OPTIONS="xmms vertical resize" . "$UZBL_UTIL_DIR/dmenu.sh" . "$UZBL_UTIL_DIR/uzbl-dir.sh" +. "$UZBL_UTIL_DIR/uzbl-util.sh" [ -r "$UZBL_BOOKMARKS_FILE" ] || exit 1 @@ -18,5 +19,5 @@ else goto="$( $DMENU < "$UZBL_BOOKMARKS_FILE" | cut -d ' ' -f 1 )" fi -[ -n "$goto" ] && printf "uri $goto\n" > "$UZBL_FIFO" -#[ -n "$goto" ] && printf "uri $goto\n" | socat - "unix-connect:$UZBL_SOCKET" +[ -n "$goto" ] && print "uri $goto\n" > "$UZBL_FIFO" +#[ -n "$goto" ] && print "uri $goto\n" | socat - "unix-connect:$UZBL_SOCKET" diff --git a/examples/data/scripts/load_url_from_history.sh b/examples/data/scripts/load_url_from_history.sh index 3537b35..0a6769a 100755 --- a/examples/data/scripts/load_url_from_history.sh +++ b/examples/data/scripts/load_url_from_history.sh @@ -5,6 +5,7 @@ DMENU_OPTIONS="xmms vertical resize" . "$UZBL_UTIL_DIR/dmenu.sh" . "$UZBL_UTIL_DIR/uzbl-dir.sh" +. "$UZBL_UTIL_DIR/uzbl-util.sh" [ -r "$UZBL_HISTORY_FILE" ] || exit 1 @@ -18,5 +19,5 @@ else goto="$( tac "$UZBL_HISTORY_FILE" | $DMENU | cut -d ' ' -f -3 | awk '{ print $NF }' )" fi -[ -n "$goto" ] && printf "uri $goto\n" > "$UZBL_FIFO" -#[ -n "$goto" ] && printf "uri $goto\n" | socat - "unix-connect:$UZBL_SOCKET" +[ -n "$goto" ] && print "uri $goto\n" > "$UZBL_FIFO" +#[ -n "$goto" ] && print "uri $goto\n" | socat - "unix-connect:$UZBL_SOCKET" diff --git a/examples/data/scripts/session.sh b/examples/data/scripts/session.sh index e2f97fe..d03554b 100755 --- a/examples/data/scripts/session.sh +++ b/examples/data/scripts/session.sh @@ -26,6 +26,8 @@ if [ -z "$UZBL_UTIL_DIR" ]; then fi . "$UZBL_UTIL_DIR/uzbl-dir.sh" +. "$UZBL_UTIL_DIR/uzbl-util.sh" + [ -d "$UZBL_DATA_DIR" ] || exit 1 UZBL="uzbl-browser -c \"$UZBL_CONFIG_FILE\"" # add custom flags and whatever here. @@ -53,27 +55,27 @@ case $act in "endinstance") if [ -z "$UZBL_FIFO" ]; then - printf "session manager: endinstance must be called from uzbl\n" + print "session manager: endinstance must be called from uzbl\n" exit 1 fi - [ "$UZBL_URI" != "(null)" ] && printf "$UZBL_URI\n" >> "$UZBL_SESSION_FILE" - printf "exit\n" > "$UZBL_FIFO" + [ "$UZBL_URI" != "(null)" ] && print "$UZBL_URI\n" >> "$UZBL_SESSION_FILE" + print "exit\n" > "$UZBL_FIFO" ;; "endsession") for fifo in "$UZBL_FIFO_DIR/uzbl_fifo_*"; do if [ "$fifo" != "$UZBL_FIFO" ]; then - printf "spawn $scriptfile endinstance\n" > "$fifo" + print "spawn $scriptfile endinstance\n" > "$fifo" fi done - [ -z "$UZBL_FIFO" ] || printf "spawn $scriptfile endinstance\n" > "$UZBL_FIFO" + [ -z "$UZBL_FIFO" ] || print "spawn $scriptfile endinstance\n" > "$UZBL_FIFO" ;; *) - printf "session manager: bad action\n" - printf "Usage: $scriptfile [COMMAND] where commands are:\n" - printf " launch - Restore a saved session or start a new one\n" - printf " endinstance - Quit the current instance. Must be called from uzbl\n" - printf " endsession - Quit the running session.\n" + print "session manager: bad action\n" + print "Usage: $scriptfile [COMMAND] where commands are:\n" + print " launch - Restore a saved session or start a new one\n" + print " endinstance - Quit the current instance. Must be called from uzbl\n" + print " endsession - Quit the running session.\n" ;; esac -- cgit v1.2.3