aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorGravatar Ben Boeckel <MathStuf@gmail.com>2011-03-10 20:51:33 -0500
committerGravatar Ben Boeckel <MathStuf@gmail.com>2011-03-10 22:32:30 -0500
commit68b6074307106718c8e6cea9f280a81f3c42306c (patch)
treed7c785a3c9327d9bc55a857d9afa12f827d63ee2 /examples
parent7027c47d10d4f6595f8b926516fcbc90eb18d574 (diff)
Don't use cat when the recipient takes a file arg
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/data/scripts/formfiller.sh27
1 files changed, 12 insertions, 15 deletions
diff --git a/examples/data/scripts/formfiller.sh b/examples/data/scripts/formfiller.sh
index 637a98f..f595eed 100755
--- a/examples/data/scripts/formfiller.sh
+++ b/examples/data/scripts/formfiller.sh
@@ -123,9 +123,8 @@ insertFunction="function insert(fname, ftype, fvalue, fchecked) { \
if [ "$action" = 'load' ]; then
[ -e "$UZBL_FORMS_DIR/$domain" ] || exit 2
- if [ "$( cat "$UZBL_FORMS_DIR/$domain" | grep "!profile" | wc -l )" -gt 1 ]; then
- menu="$( cat "$UZBL_FORMS_DIR/$domain" | \
- sed -n -e 's/^!profile=\([^[:blank:]]\+\)/\1/p' )"
+ if [ "$( grep "!profile" "$UZBL_FORMS_DIR/$domain" | wc -l )" -gt 1 ]; then
+ menu="$( sed -n -e 's/^!profile=\([^[:blank:]]\+\)/\1/p' "$UZBL_FORMS_DIR/$domain" )"
option="$( printf "$menu" | $DMENU )"
fi
@@ -133,13 +132,12 @@ if [ "$action" = 'load' ]; then
sed -i -e '/^>/d' "$tmpfile"
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' "$UZBL_FORMS_DIR/$domain"
- fields="$( cat "$UZBL_FORMS_DIR/$domain" | \
- sed -n -e "/^!profile=${option}/,/^!profile=/p" | \
- sed -e '/^!profile=/d' | \
- sed -e 's/^\([^(]\+(\)\(radio\|checkbox\|text\|search\|textarea\|password\)):/%{>\1\2):<}%/' | \
- sed -e 's/^\(.\+\)$/<{br}>\1/' | \
- tr -d '\n' | \
- sed -e 's/<{br}>%{>\([^(]\+(\)\(radio\|checkbox\|text\|search\|textarea\|password\)):<}%/\\n\1\2):/g' )"
+ fields="$( sed -n -e "/^!profile=${option}/,/^!profile=/p" "$UZBL_FORMS_DIR/$domain" | \
+ sed -e '/^!profile=/d' | \
+ sed -e 's/^\([^(]\+(\)\(radio\|checkbox\|text\|search\|textarea\|password\)):/%{>\1\2):<}%/' | \
+ sed -e 's/^\(.\+\)$/<{br}>\1/' | \
+ tr -d '\n' | \
+ sed -e 's/<{br}>%{>\([^(]\+(\)\(radio\|checkbox\|text\|search\|textarea\|password\)):<}%/\\n\1\2):/g' )"
printf '%s\n' "${fields}" | \
sed -n -e "s/\([^(]\+\)(\(password\|text\|search\|textarea\)\+):[ ]*\(.\+\)/js $insertFunction; insert('\1', '\2', '\3', 0);/p" | \
sed -e 's/@/\\@/g;s/<{br}>/\\\\n/g' | socat - "unix-connect:$UZBL_SOCKET"
@@ -160,11 +158,10 @@ elif [ "$action" = "once" ]; then
sed -i -e '/^>/d' "$tmpfile"
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' "$tmpfile"
- fields="$( cat "$tmpfile" | \
- sed -e 's/^\([^(]\+(\)\(radio\|checkbox\|text\|search\|textarea\|password\)):/%{>\1\2):<}%/' | \
- sed -e 's/^\(.\+\)$/<{br}>\1/' | \
- tr -d '\n' | \
- sed -e 's/<{br}>%{>\([^(]\+(\)\(radio\|checkbox\|text\|search\|textarea\|password\)):<}%/\\n\1\2):/g' )"
+ fields="$( sed -e 's/^\([^(]\+(\)\(radio\|checkbox\|text\|search\|textarea\|password\)):/%{>\1\2):<}%/' "$tmpfile" | \
+ sed -e 's/^\(.\+\)$/<{br}>\1/' | \
+ tr -d '\n' | \
+ sed -e 's/<{br}>%{>\([^(]\+(\)\(radio\|checkbox\|text\|search\|textarea\|password\)):<}%/\\n\1\2):/g' )"
printf '%s\n' "${fields}" | \
sed -n -e "s/\([^(]\+\)(\(password\|text\|search\|textarea\)\+):[ ]*\(.\+\)/js $insertFunction; insert('\1', '\2', '\3', 0);/p" | \
sed -e 's/@/\\@/g;s/<{br}>/\\\\n/g' | socat - "unix-connect:$UZBL_SOCKET"