代码: 全选
#Toggle the values of variables controlling optional shell behavior.
#use nocasematch must use [[]]?
shopt -s nocasematch
if [[ "$1" == /* ]]
then
currpath="$1"
else
currpath="$(pwd)/$1"
fi
for i in $(echo "$1"|sed 's/[^.]*.\([a-zA-Z]*\)/\1/g')
do
if [[ "$i" == "jpg" ]] || [[ "$i" == "png" ]] || [[ "$i" == "gif" ]] || [[ "$i" == "jpeg" ]] || [[ "$i" == "svg" ]]
then
curl -F "name=@$currpath" http://img.vim-cn.com/
else
cat $currpath| curl -F "vimcn=<-" http://p.vim-cn.com
fi
done
shopt -s nocasematch
if语句
if [[ "$i" == "jpg" ]] || [[ "$i" == "png" ]] || [[ "$i" == "gif" ]] || [[ "$i" == "jpeg" ]] || [[ "$i" == "svg" ]]
是可以匹配到大写和小写的,也就是说,PNG和png都可以匹配
如果吧上面的If语句中两个[[都改成一个[,就不能匹配大写了
bash语法有点乱,求点播
