Mercurial > ec-dotfiles
changeset 229:b03fef57b465
- Fixed getopts, now that I remember where I take the code from
author | edhoprima@gmail.com <edhoprima@gmail.com> |
---|---|
date | Sun, 27 Dec 2009 19:18:02 +0000 |
parents | 5d3a0645b504 |
children | e922fb1e858f |
files | moefetch.sh |
diffstat | 1 files changed, 10 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/moefetch.sh Tue Dec 15 04:39:46 2009 +0000 +++ b/moefetch.sh Sun Dec 27 19:18:02 2009 +0000 @@ -138,7 +138,7 @@ </xsl:stylesheet> EOF __tempnum=$(echo $(wc -l < "${TEMP_PREFIX}-templist")) - __iternum=$((__iternum + 1)) + __iternum=$((${__iternum} + 1)) cat "${TEMP_PREFIX}-templist" >> "${TEMP_PREFIX}-list" echo "${__tempnum} file(s) available" done @@ -170,10 +170,10 @@ numfiles=0 for dircontent in "${*}/"* "${*}/".*; do if [ "${dircontent}" != "${*}/*" ] || [ -e "${dircontent}" ]; then - numfiles=$((numfiles + 1)) + numfiles=$((${numfiles} + 1)) fi done - echo $((numfiles - 2)) + echo $((${numfiles} - 2)) } # check tools availability @@ -341,10 +341,10 @@ ;; esac shift - SITE= - TAGS= __has_pass=0 __has_user=0 + #copypasta from http://mywiki.wooledge.org/BashFAQ/035 + __optnum=1 while getopts "s:(site)n(noclean)u:(user)p:(password)" opt do case "$opt" in @@ -359,7 +359,9 @@ __has_user=1 ;; esac + __optnum="${OPTIND}" done + shift $((${__optnum}-1)) TAGS="$@" [ -n "${SITE}" ] || SITE=${DEFAULT_SITE} [ -n "${TAGS}" ] || Err_Fatal "No tag specified" @@ -380,8 +382,11 @@ # global variables goes here init_globals() { + cd . # Reset ${PWD} _version="0.3-beta3" # version of this script _use_login=0 # variable to check whether a login is used or not + SITE= + TAGS= } main()