aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Brendan Taylor <whateley@gmail.com>2011-03-13 21:49:27 -0600
committerGravatar Brendan Taylor <whateley@gmail.com>2011-03-13 21:49:27 -0600
commit32f6f8360684c0b583e613cf5727f0c102438bd2 (patch)
treef36a5441ca4c075687649740a0143bddee189be1
parent5ec505fdb007d22bcfb5631e88e67038b06d778a (diff)
sh scripts: replace print with echo/printf
we can safely use echo in many of the situations where 'print' is being used, and we can use printf directly in other places.
-rwxr-xr-xexamples/data/scripts/download.sh5
-rwxr-xr-xexamples/data/scripts/go_input.sh6
-rwxr-xr-xexamples/data/scripts/history.sh2
-rwxr-xr-xexamples/data/scripts/insert_bookmark.sh3
-rwxr-xr-xexamples/data/scripts/instance-select-wmii.sh5
-rwxr-xr-xexamples/data/scripts/load_url_from_bookmarks.sh5
-rwxr-xr-xexamples/data/scripts/load_url_from_history.sh5
-rwxr-xr-xexamples/data/scripts/session.sh21
-rw-r--r--examples/data/scripts/util/uzbl-util.sh3
-rw-r--r--examples/data/scripts/util/uzbl-window.sh10
10 files changed, 26 insertions, 39 deletions
diff --git a/examples/data/scripts/download.sh b/examples/data/scripts/download.sh
index 8b4761f..7753bd6 100755
--- a/examples/data/scripts/download.sh
+++ b/examples/data/scripts/download.sh
@@ -7,12 +7,11 @@
# 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="$( print "$uri" | sed -e 's/\W/-/g' )"
+safe_uri="$( echo "$uri" | sed -e 's/\W/-/g' )"
# a filename suggested by the server or based on the URL
suggested_filename="${2:-$safe_uri}"
@@ -25,4 +24,4 @@ content_type="$3"
total_size="$4"
# just save the file to the default directory with the suggested name
-print "$UZBL_DOWNLOAD_DIR/$suggested_filename\n"
+echo "$UZBL_DOWNLOAD_DIR/$suggested_filename"
diff --git a/examples/data/scripts/go_input.sh b/examples/data/scripts/go_input.sh
index ad236d1..9797788 100755
--- a/examples/data/scripts/go_input.sh
+++ b/examples/data/scripts/go_input.sh
@@ -1,9 +1,7 @@
#!/bin/sh
-. "$UZBL_UTIL_DIR/uzbl-util.sh"
-
-case "$( print "script @scripts_dir/go_input.js\n" | socat - "unix-connect:$UZBL_SOCKET" )" in
+case "$( echo "script @scripts_dir/go_input.js" | socat - "unix-connect:$UZBL_SOCKET" )" in
*XXXEMIT_FORM_ACTIVEXXX*)
- print "event FORM_ACTIVE\n" > "$UZBL_FIFO"
+ echo "event FORM_ACTIVE" > "$UZBL_FIFO"
;;
esac
diff --git a/examples/data/scripts/history.sh b/examples/data/scripts/history.sh
index d1e3c0f..0709b5e 100755
--- a/examples/data/scripts/history.sh
+++ b/examples/data/scripts/history.sh
@@ -4,4 +4,4 @@
>> "$UZBL_HISTORY_FILE" || exit 1
-print "$( date +'%Y-%m-%d %H:%M:%S' ) $UZBL_URI $UZBL_TITLE\n" >> "$UZBL_HISTORY_FILE"
+echo "$( date +'%Y-%m-%d %H:%M:%S' ) $UZBL_URI $UZBL_TITLE" >> "$UZBL_HISTORY_FILE"
diff --git a/examples/data/scripts/insert_bookmark.sh b/examples/data/scripts/insert_bookmark.sh
index 5d41131..f310e49 100755
--- a/examples/data/scripts/insert_bookmark.sh
+++ b/examples/data/scripts/insert_bookmark.sh
@@ -1,7 +1,6 @@
#!/bin/sh
. "$UZBL_UTIL_DIR/uzbl-dir.sh"
-. "$UZBL_UTIL_DIR/uzbl-util.sh"
>> "$UZBL_BOOKMARKS_FILE" || exit 1
@@ -12,4 +11,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
-print "$UZBL_URI $tags\n" >> "$UZBL_BOOKMARKS_FILE"
+echo "$UZBL_URI $tags" >> "$UZBL_BOOKMARKS_FILE"
diff --git a/examples/data/scripts/instance-select-wmii.sh b/examples/data/scripts/instance-select-wmii.sh
index d340dda..b2aadbb 100755
--- a/examples/data/scripts/instance-select-wmii.sh
+++ b/examples/data/scripts/instance-select-wmii.sh
@@ -13,7 +13,6 @@
DMENU_SCHEME="wmii"
. "$UZBL_UTIL_DIR/dmenu.sh"
-. "$UZBL_UTIL_DIR/uzbl-util.sh"
case "$1" in
"list")
@@ -23,7 +22,7 @@ case "$1" in
label="$( wmiir read /client/$i/label )"
list="$list$i : $label\n"
done
- window="$( print "$list\n" | $DMENU | cut -d ' ' -f 1 )"
+ window="$( echo "$list" | $DMENU | cut -d ' ' -f 1 )"
wmiir xwrite /tag/sel/ctl "select client $window"
;;
"next")
@@ -42,7 +41,7 @@ case "$1" in
fi
;;
* )
- print "$1 not valid\n" >&2
+ echo "$1 not valid" >&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 30417f1..a03db4b 100755
--- a/examples/data/scripts/load_url_from_bookmarks.sh
+++ b/examples/data/scripts/load_url_from_bookmarks.sh
@@ -7,7 +7,6 @@ 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
@@ -19,5 +18,5 @@ else
goto="$( $DMENU < "$UZBL_BOOKMARKS_FILE" | cut -d ' ' -f 1 )"
fi
-[ -n "$goto" ] && print "uri $goto\n" > "$UZBL_FIFO"
-#[ -n "$goto" ] && print "uri $goto\n" | socat - "unix-connect:$UZBL_SOCKET"
+[ -n "$goto" ] && echo "uri $goto" > "$UZBL_FIFO"
+#[ -n "$goto" ] && echo "uri $goto" | 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 0a6769a..24bfdce 100755
--- a/examples/data/scripts/load_url_from_history.sh
+++ b/examples/data/scripts/load_url_from_history.sh
@@ -5,7 +5,6 @@ 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
@@ -19,5 +18,5 @@ else
goto="$( tac "$UZBL_HISTORY_FILE" | $DMENU | cut -d ' ' -f -3 | awk '{ print $NF }' )"
fi
-[ -n "$goto" ] && print "uri $goto\n" > "$UZBL_FIFO"
-#[ -n "$goto" ] && print "uri $goto\n" | socat - "unix-connect:$UZBL_SOCKET"
+[ -n "$goto" ] && echo "uri $goto" > "$UZBL_FIFO"
+#[ -n "$goto" ] && echo "uri $goto" | socat - "unix-connect:$UZBL_SOCKET"
diff --git a/examples/data/scripts/session.sh b/examples/data/scripts/session.sh
index d03554b..4e7bfd1 100755
--- a/examples/data/scripts/session.sh
+++ b/examples/data/scripts/session.sh
@@ -26,7 +26,6 @@ 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
@@ -55,27 +54,27 @@ case $act in
"endinstance")
if [ -z "$UZBL_FIFO" ]; then
- print "session manager: endinstance must be called from uzbl\n"
+ echo "session manager: endinstance must be called from uzbl"
exit 1
fi
- [ "$UZBL_URI" != "(null)" ] && print "$UZBL_URI\n" >> "$UZBL_SESSION_FILE"
- print "exit\n" > "$UZBL_FIFO"
+ [ "$UZBL_URI" != "(null)" ] && echo "$UZBL_URI" >> "$UZBL_SESSION_FILE"
+ echo "exit" > "$UZBL_FIFO"
;;
"endsession")
for fifo in "$UZBL_FIFO_DIR/uzbl_fifo_*"; do
if [ "$fifo" != "$UZBL_FIFO" ]; then
- print "spawn $scriptfile endinstance\n" > "$fifo"
+ echo "spawn $scriptfile endinstance" > "$fifo"
fi
done
- [ -z "$UZBL_FIFO" ] || print "spawn $scriptfile endinstance\n" > "$UZBL_FIFO"
+ [ -z "$UZBL_FIFO" ] || echo "spawn $scriptfile endinstance" > "$UZBL_FIFO"
;;
*)
- 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"
+ 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."
;;
esac
diff --git a/examples/data/scripts/util/uzbl-util.sh b/examples/data/scripts/util/uzbl-util.sh
deleted file mode 100644
index 7e0bd99..0000000
--- a/examples/data/scripts/util/uzbl-util.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-alias print="printf %b"
diff --git a/examples/data/scripts/util/uzbl-window.sh b/examples/data/scripts/util/uzbl-window.sh
index 856e5fa..4b96372 100644
--- a/examples/data/scripts/util/uzbl-window.sh
+++ b/examples/data/scripts/util/uzbl-window.sh
@@ -1,13 +1,11 @@
#!/bin/sh
# uzbl window detection
-. "$UZBL_UTIL_DIR/uzbl-util.sh"
-
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="$( print "$UZBL_WIN_POS" | cut -d ' ' -f 1 )"
-UZBL_WIN_POS_Y="$( print "$UZBL_WIN_POS" | cut -d ' ' -f 2 )"
-UZBL_WIN_WIDTH="$( print "$UZBL_WIN_SIZE" | cut -d ' ' -f 1 )"
-UZBL_WIN_HEIGHT="$( print "$UZBL_WIN_SIZE" | cut -d ' ' -f 2 )"
+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 )"