comparison moefetch.sh @ 158:cba73f6a96bb

grep check. OpenSolaris' default grep doesn't support -f
author edhoprima
date Tue, 05 May 2009 17:56:54 +0000
parents ffca564daefa
children 75fe19903b74
comparison
equal deleted inserted replaced
157:ffca564daefa 158:cba73f6a96bb
20 # what it does: fetch every picture that has the specified tags. 20 # what it does: fetch every picture that has the specified tags.
21 21
22 # requirement: wget, libxslt, md5sum (or md5) 22 # requirement: wget, libxslt, md5sum (or md5)
23 23
24 # configs 24 # configs
25 # program additional paths for: cut, sed, wc, md5(sum), wget, xsltproc 25 # program additional paths for: cut, sed, wc, md5(sum), wget, xsltproc, grep
26 extrapath= 26 extrapath=
27 27
28 # md5 calculation, expected output: <32digit md5><space(s)><filename> 28 # md5 calculation, expected output: <32digit md5><space(s)><filename>
29 # gnu: "md5sum", bsd: "md5 -r" 29 # gnu: "md5sum", bsd: "md5 -r"
30 md5="md5 -r" 30 md5="md5 -r"
117 fi 117 fi
118 } 118 }
119 119
120 120
121 # path initialization 121 # path initialization
122 export PATH=${PATH}:$extrapath 122 export PATH=$extrapath:${PATH}
123 123
124 # verify all programs required do indeed exist 124 # verify all programs required do indeed exist
125
126
125 # basic tools 127 # basic tools
126 commands="cut sed wc wget xsltproc xargs rm mkdir chown comm" 128 commands="cut sed wc wget xsltproc xargs rm mkdir chown comm grep"
127 cmderr=" " 129 cmderr=" "
128 for cmd in $commands 130 for cmd in $commands
129 do 131 do
130 command -v "$cmd" >/dev/null || cmderr="$cmderr $cmd" 132 command -v "$cmd" >/dev/null || cmderr="$cmderr $cmd"
131 done 133 done
142 mdtest= 144 mdtest=
143 if [ `echo test | $md5 | cut -d ' ' -f 1 -` != "d8e8fca2dc0f896fd7cb4cb0031ba249" ]; then 145 if [ `echo test | $md5 | cut -d ' ' -f 1 -` != "d8e8fca2dc0f896fd7cb4cb0031ba249" ]; then
144 echo "$md5 doesn't produce wanted output" 146 echo "$md5 doesn't produce wanted output"
145 exit 1 147 exit 1
146 fi 148 fi
149
150 # grep checking
151 # originally created for workaround on solaris
152 #if [ `uname` = "SunOS" ]; then
153 FAIL=0
154 echo "blah" > superrandomtestfile
155 echo "blah" > superrandomtestfile.2
156 grep -f superrandomtestfile.2 superrandomtestfile > /dev/null 2>&1 || FAIL=1
157 rm superrandomtestfile superrandomtestfile.2 superrandomtestfile.3 > /dev/null 2>&1
158 if [ $FAIL = 1 ]; then
159 echo "Your grep is not compatible. Please install or set path of correct grep"
160 exit 1
161 fi
162 #fi
147 163
148 164
149 # all green (part 1)! let's go (until we check the tag) 165 # all green (part 1)! let's go (until we check the tag)
150 166
151 # initialization 167 # initialization