inbrowse (webrowse-2.0.0.tgz) | : | inbrowse (webrowse-2.0.3.tgz) | ||
---|---|---|---|---|
#!/bin/sh - | #!/bin/sh - | |||
inbrowser=webrowse | inbrowser=webrowse | |||
mailbrowser=mimebrowse | mailbrowser=mimebrowse | |||
xthost= | ||||
xterm='xterm -e ssh' | ||||
goapp= | ||||
case "${USER-$LOGNAME}" in | ||||
kinzler) xthost=,`hosts | grep -v '\.' | tr '\012' ,` | ||||
xterm=xt | ||||
goapp=,`"$APPENV"/bin/app ALL echo | tr '\012' ,`;; | ||||
esac | ||||
# inbrowse - web browse the given standard input, guessing its nature | # inbrowse - web browse the given standard input, guessing its nature | |||
# Steve Kinzler, steve@kinzler.com, Feb 99/Mar 00/Jul 05 | # Steve Kinzler, steve@kinzler.com, Feb 99/Mar 00/Jul 05 | |||
# see website http://kinzler.com/me/webrowse/ | # see website http://kinzler.com/me/webrowse/ | |||
# http://kinzler.com/me/home.html#web | # http://kinzler.com/me/home.html#web | |||
case "$1" in | case "$1" in | |||
-h) cat << EOF 1>&2 | -h) cat << EOF 1>&2 | |||
usage: $0 [ $inbrowser options ] | usage: $0 [ $inbrowser options ] If the standard input is just the word | |||
If the standard input is just the word "reload", it's taken as a browser | "reload", it's taken as a browser command to run. If the stdin is a | |||
command to run. If the stdin is a single line without whitespace, it's | single line beginning with the word "go", it's taken as a command to run. | |||
taken as a URL piece to browse. Otherwise, if the stdin resembles an | If the stdin is a single line without whitespace, it's taken as a URL | |||
email message, it's browsed with a mail browser ($mailbrowser), if any. | piece to browse. Otherwise, if the stdin resembles an email message, | |||
Otherwise, the stdin is searched for anything resembling HTML or XML and, | it's browsed with a mail browser ($mailbrowser), if any. Otherwise, | |||
if found, is taken to be an HTML or XML page to display. Otherwise, | the stdin is searched for anything resembling HTML or XML and, if found, | |||
it's taken as text and displayed with any targets marked up. | is taken to be an HTML or XML page to display. Otherwise, it's taken | |||
as text and displayed with any targets marked up. | ||||
EOF | EOF | |||
exit 1;; | exit 1;; | |||
esac | esac | |||
tmp=/tmp/br$$ | tmp=/tmp/br$$ | |||
trap "rm -f $tmp; exit" 0 1 2 13 15 | trap "rm -f $tmp; exit" 0 1 2 13 15 | |||
cat > $tmp || exit $? # Note: input may not be newline-terminated | cat > $tmp || exit $? # Note: input may not be newline-terminated | |||
args= | args= | |||
case "`wc -l < $tmp`" in | case "`wc -l < $tmp`" in | |||
[01]|*\ [01]) | [01]|*\ [01]) | |||
line="`cat < $tmp`" | line="`cat < $tmp`" | |||
case "$line" in | case "$line" in | |||
'') exit 2;; | '') exit 2;; | |||
reload) args="-c $line";; | reload) args="-c $line";; | |||
go\ *) exec $line;; | ||||
?*[\ \ ]*?) ;; | ?*[\ \ ]*?) ;; | |||
*) case "$line" in | *) case "$line" in | |||
['(<[{']*['}]>)']|['"'"'"]*["'"'"']) | ['(<[{']*['}]>)']|['"'"'"]*["'"'"']) | |||
line=`echo "$line" | sed 's/.//; s/.$//'`;; | line=`echo "$line" | sed 's/.//; s/.$//'`;; | |||
esac | ||||
case "$xthost" in | ||||
*,$line,*) exec $xterm "$line";; | ||||
esac | ||||
case "$goapp" in | ||||
*,$line,*) exec go app:"$line";; | ||||
esac | esac | |||
case "$line" in | case "$line" in | |||
*.*) ;; | *[:/.]*) ;; | |||
*) line="$line.com";; | *) line="$line.com";; | |||
esac | esac | |||
case "$line" in | case "$line" in | |||
*:/*) ;; | *:/*) ;; | |||
www*|my.*|ftp*|[0-9]*[0-9]) | www*|my.*|ftp*|[0-9]*[0-9]) | |||
line="http://$line";; | line="http://$line";; | |||
/*) line=http://`echo "$line" | sed s/.//`;; | /*) line=http://`echo "$line" | sed s/.//`;; | |||
*) line="http://www.$line";; | *) line="http://www.$line";; | |||
esac | esac | |||
args="-u $line";; | args="-u $line";; | |||
esac | esac | |||
case "$args" in | case "$args" in | |||
?*) $inbrowser ${1+"$@"} $args < $tmp; exit $?;; | ?*) $inbrowser ${1+"$@"} $args < $tmp; exit $?;; | |||
esac;; | esac;; | |||
esac | esac | |||
case "$mailbrowser" in | case "$mailbrowser" in | |||
?*) case "`sed -n '/^From[ :].*@.*\./p; 1q' < $tmp`" in | ?*) case "`sed -n '/^From[ :].*@.*\./p; 1q' < $tmp`" in | |||
End of changes. 7 change blocks. | ||||
15 lines changed or deleted | 32 lines changed or added |