aboutsummaryrefslogtreecommitdiff
path: root/html2markdown
diff options
context:
space:
mode:
authorroktas <roktas@788f1e2b-df1e-0410-8736-df70ead52e1b>2006-11-12 21:17:06 +0000
committerroktas <roktas@788f1e2b-df1e-0410-8736-df70ead52e1b>2006-11-12 21:17:06 +0000
commit2763382dd803916e34e6575904147d7e3594a7f6 (patch)
treec87b10e109f87a7336b9b4022ef2da6314757290 /html2markdown
parent8e5f3e684c13a4b48d0ed24a15560f2631fc8e93 (diff)
downloadpandoc-2763382dd803916e34e6575904147d7e3594a7f6.tar.gz
Replace which(1) in all wrappers with 'pathfind', a POSIX-compliant shell
function. Expand tabs to four spaces. git-svn-id: https://pandoc.googlecode.com/svn/trunk@94 788f1e2b-df1e-0410-8736-df70ead52e1b
Diffstat (limited to 'html2markdown')
-rw-r--r--html2markdown23
1 files changed, 18 insertions, 5 deletions
diff --git a/html2markdown b/html2markdown
index 48232acbb..4320ce9b1 100644
--- a/html2markdown
+++ b/html2markdown
@@ -2,11 +2,24 @@
# converts html to markdown
# uses an available program to fetch URL and tidy to normalize it first
+pathfind () { # portable which(1), code taken from Debian Developer's Reference
+ OLDIFS="$IFS"
+ IFS=:
+ for _p in $PATH; do
+ if [ -x "$_p/$*" ]; then
+ IFS="$OLDIFS"
+ return 0
+ fi
+ done
+ IFS="$OLDIFS"
+ return 1
+}
+
for p in pandoc tidy; do
- which $p >/dev/null 2>&1 || {
- echo >&2 "You need '$p' to use this program!"
- exit 1
- }
+ pathfind $p || {
+ echo >&2 "You need '$p' to use this program!"
+ exit 1
+ }
done
if [ -z "$1" ] || [ -f $1 ]; then
@@ -17,7 +30,7 @@ else
# Treat given argument as an URL. Locate a
# sensible text based browser (note the order).
for p in wget lynx w3m curl links w3c; do
- if which $p >/dev/null 2>&1; then
+ if pathfind $p; then
DUMPER=$p
break
fi