From 5f2a6b9371fcf2ca78143cd255242e1cacac6ad1 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 10 Mar 2011 21:09:03 -0500 Subject: Use printf rather than echo --- examples/data/scripts/download.sh | 4 ++-- examples/data/scripts/follow.sh | 8 ++++---- examples/data/scripts/formfiller.sh | 6 +++--- examples/data/scripts/go_input.sh | 4 ++-- examples/data/scripts/history.sh | 2 +- examples/data/scripts/insert_bookmark.sh | 2 +- examples/data/scripts/instance-select-wmii.sh | 2 +- examples/data/scripts/load_url_from_bookmarks.sh | 4 ++-- examples/data/scripts/load_url_from_history.sh | 4 ++-- examples/data/scripts/session.sh | 20 ++++++++++---------- examples/data/scripts/util/uzbl-window.sh | 8 ++++---- 11 files changed, 32 insertions(+), 32 deletions(-) diff --git a/examples/data/scripts/download.sh b/examples/data/scripts/download.sh index 7753bd6..448e086 100755 --- a/examples/data/scripts/download.sh +++ b/examples/data/scripts/download.sh @@ -11,7 +11,7 @@ # the URL that is being downloaded uri="$1" -safe_uri="$( echo "$uri" | sed -e 's/\W/-/g' )" +safe_uri="$( printf "$uri" | sed -e 's/\W/-/g' )" # a filename suggested by the server or based on the URL suggested_filename="${2:-$safe_uri}" @@ -24,4 +24,4 @@ content_type="$3" total_size="$4" # just save the file to the default directory with the suggested name -echo "$UZBL_DOWNLOAD_DIR/$suggested_filename" +printf "$UZBL_DOWNLOAD_DIR/$suggested_filename\n" diff --git a/examples/data/scripts/follow.sh b/examples/data/scripts/follow.sh index ba1bab4..b038c12 100755 --- a/examples/data/scripts/follow.sh +++ b/examples/data/scripts/follow.sh @@ -9,18 +9,18 @@ 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 - echo "script @scripts_dir/follow.js \"@{follow_hint_keys} $keys\"" > "$UZBL_FIFO" + printf "script @scripts_dir/follow.js \"@{follow_hint_keys} $keys\"\n" > "$UZBL_FIFO" exit fi -result="$( echo "script @scripts_dir/follow.js \"@{follow_hint_keys} $keys\"" | socat - "unix-connect:$UZBL_SOCKET" )" +result="$( printf "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 - echo 'event FORM_ACTIVE' > "$UZBL_FIFO" + printf "event FORM_ACTIVE\n" > "$UZBL_FIFO" ;; *XXXRESET_MODEXXX*) # a link was selected, reset uzbl's input mode - echo 'set mode=' > "$UZBL_FIFO" + printf "set mode=\n" > "$UZBL_FIFO" ;; esac diff --git a/examples/data/scripts/formfiller.sh b/examples/data/scripts/formfiller.sh index 4b4fb4e..2895e5b 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="$( echo "$UZBL_URI" | sed -e 's/\(http\|https\):\/\/\([^\/]\+\)\/.*/\2/' )" +domain="$( printf "$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 @@ -147,7 +147,7 @@ elif [ "$action" = "once" ]; then printf "js %s dump();\n" "$dumpFunction" | \ socat - "unix-connect:$UZBL_SOCKET" | \ sed -n -e '/^[^(]\+([^)]\+):/p' > "$tmpfile" - echo "$MODELINE" >> "$tmpfile" + printf "$MODELINE\n" >> "$tmpfile" $UZBL_EDITOR "$tmpfile" [ -e "$tmpfile" ] || exit 2 @@ -170,7 +170,7 @@ elif [ "$action" = "once" ]; then else if [ "$action" = 'new' -o "$action" = 'add' ]; then [ "$action" = 'new' ] && echo "$MODELINE" > "$form_file" - echo "!profile=NAME_THIS_PROFILE$RAND" >> "$form_file" + printf "!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 c3c966b..6574a83 100755 --- a/examples/data/scripts/go_input.sh +++ b/examples/data/scripts/go_input.sh @@ -1,7 +1,7 @@ #!/bin/sh -case "$( echo 'script @scripts_dir/go_input.js' | socat - "unix-connect:$UZBL_SOCKET" )" in +case "$( printf "script @scripts_dir/go_input.js\n" | socat - "unix-connect:$UZBL_SOCKET" )" in *XXXEMIT_FORM_ACTIVEXXX*) - echo 'event FORM_ACTIVE' > "$UZBL_FIFO" + printf "event FORM_ACTIVE\n" > "$UZBL_FIFO" ;; esac diff --git a/examples/data/scripts/history.sh b/examples/data/scripts/history.sh index bbef20a..4b660c3 100755 --- a/examples/data/scripts/history.sh +++ b/examples/data/scripts/history.sh @@ -4,4 +4,4 @@ [ -w "$UZBL_HISTORY_FILE" ] || [ ! -a "$UZBL_HISTORY_FILE" ] || exit 1 -echo "$( date +'%Y-%m-%d %H:%M:%S' ) $UZBL_URI $UZBL_TITLE" >> "$UZBL_HISTORY_FILE" +printf "$( 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 b1ea07d..d4c6773 100755 --- a/examples/data/scripts/insert_bookmark.sh +++ b/examples/data/scripts/insert_bookmark.sh @@ -12,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 -echo "$UZBL_URI $tags" >> "$UZBL_BOOKMARKS_FILE" +printf "$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 ec6a3c1..c12f7b7 100755 --- a/examples/data/scripts/instance-select-wmii.sh +++ b/examples/data/scripts/instance-select-wmii.sh @@ -41,7 +41,7 @@ case "$1" in fi ;; * ) - echo "$1 not valid" >&2 + printf "$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 a03db4b..d7bf104 100755 --- a/examples/data/scripts/load_url_from_bookmarks.sh +++ b/examples/data/scripts/load_url_from_bookmarks.sh @@ -18,5 +18,5 @@ else goto="$( $DMENU < "$UZBL_BOOKMARKS_FILE" | cut -d ' ' -f 1 )" fi -[ -n "$goto" ] && echo "uri $goto" > "$UZBL_FIFO" -#[ -n "$goto" ] && echo "uri $goto" | socat - "unix-connect:$UZBL_SOCKET" +[ -n "$goto" ] && printf "uri $goto\n" > "$UZBL_FIFO" +#[ -n "$goto" ] && printf "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 24bfdce..3537b35 100755 --- a/examples/data/scripts/load_url_from_history.sh +++ b/examples/data/scripts/load_url_from_history.sh @@ -18,5 +18,5 @@ else goto="$( tac "$UZBL_HISTORY_FILE" | $DMENU | cut -d ' ' -f -3 | awk '{ print $NF }' )" fi -[ -n "$goto" ] && echo "uri $goto" > "$UZBL_FIFO" -#[ -n "$goto" ] && echo "uri $goto" | socat - "unix-connect:$UZBL_SOCKET" +[ -n "$goto" ] && printf "uri $goto\n" > "$UZBL_FIFO" +#[ -n "$goto" ] && printf "uri $goto\n" | socat - "unix-connect:$UZBL_SOCKET" diff --git a/examples/data/scripts/session.sh b/examples/data/scripts/session.sh index c95a9e5..e2f97fe 100755 --- a/examples/data/scripts/session.sh +++ b/examples/data/scripts/session.sh @@ -53,27 +53,27 @@ case $act in "endinstance") if [ -z "$UZBL_FIFO" ]; then - echo "session manager: endinstance must be called from uzbl" + printf "session manager: endinstance must be called from uzbl\n" exit 1 fi - [ "$UZBL_URI" != "(null)" ] && echo "$UZBL_URI" >> "$UZBL_SESSION_FILE" - echo exit > "$UZBL_FIFO" + [ "$UZBL_URI" != "(null)" ] && printf "$UZBL_URI\n" >> "$UZBL_SESSION_FILE" + printf "exit\n" > "$UZBL_FIFO" ;; "endsession") for fifo in "$UZBL_FIFO_DIR/uzbl_fifo_*"; do if [ "$fifo" != "$UZBL_FIFO" ]; then - echo "spawn $scriptfile endinstance" > "$fifo" + printf "spawn $scriptfile endinstance\n" > "$fifo" fi done - [ -z "$UZBL_FIFO" ] || echo "spawn $scriptfile endinstance" > "$UZBL_FIFO" + [ -z "$UZBL_FIFO" ] || printf "spawn $scriptfile endinstance\n" > "$UZBL_FIFO" ;; *) - echo "session manager: bad action" - echo "Usage: $scriptfile [COMMAND] where commands are:" - echo " launch - Restore a saved session or start a new one" - echo " endinstance - Quit the current instance. Must be called from uzbl" - echo " endsession - Quit the running session." + 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" ;; esac diff --git a/examples/data/scripts/util/uzbl-window.sh b/examples/data/scripts/util/uzbl-window.sh index 351eff7..279636a 100644 --- a/examples/data/scripts/util/uzbl-window.sh +++ b/examples/data/scripts/util/uzbl-window.sh @@ -5,7 +5,7 @@ UZBL_WIN_POS="$( xwininfo -id "$UZBL_XID" | \ sed -n -e 's/Corners:[ ]*[+-]\([0-9]*\)[+-]\([0-9]*\).*$/\1 \2/p' )" UZBL_WIN_SIZE="$( xwininfo -id "$UZBL_XID" | \ sed -n -e 's/-geometry[ ]*\([0-9]*\)x\([0-9]*\).*$/\1 \2/p' )" -UZBL_WIN_POS_X="$( echo "$UZBL_WIN_POS" | cut -d ' ' -f 1 )" -UZBL_WIN_POS_Y="$( echo "$UZBL_WIN_POS" | cut -d ' ' -f 2 )" -UZBL_WIN_WIDTH="$( echo "$UZBL_WIN_SIZE" | cut -d ' ' -f 1 )" -UZBL_WIN_HEIGHT="$( echo "$UZBL_WIN_SIZE" | cut -d ' ' -f 2 )" +UZBL_WIN_POS_X="$( printf "$UZBL_WIN_POS" | cut -d ' ' -f 1 )" +UZBL_WIN_POS_Y="$( printf "$UZBL_WIN_POS" | cut -d ' ' -f 2 )" +UZBL_WIN_WIDTH="$( printf "$UZBL_WIN_SIZE" | cut -d ' ' -f 1 )" +UZBL_WIN_HEIGHT="$( printf "$UZBL_WIN_SIZE" | cut -d ' ' -f 2 )" -- cgit v1.2.3