# HG changeset patch # User edhoprima@gmail.com # Date 1246292002 0 # Node ID 3dbb5a6678f98807dbec1ae2a63894c12fbff0e3 # Parent 30d2fb6560298f6466164213b66efa5c0682e6c4 egrep is not grep diff -r 30d2fb656029 -r 3dbb5a6678f9 moefetch.sh --- a/moefetch.sh Mon Jun 29 15:40:28 2009 +0000 +++ b/moefetch.sh Mon Jun 29 16:13:22 2009 +0000 @@ -47,7 +47,6 @@ ### - unified repository to save bandwidth ### - bug stomping ### - sanity checking -### - replace grep -vf with POSIX compatible command ### WILL BE FOR 0.3 # useless welcome message. Also version @@ -90,7 +89,7 @@ printf "Processing XML file..." # xslt evilry > "${TEMP_PREFIX}-list" - xsltproc - "${TEMP_PREFIX}-xml" < "${TEMP_PREFIX}-list" 2>/dev/null + xsltproc - "${TEMP_PREFIX}-xml" < "${TEMP_PREFIX}-list" 2>/dev/null @@ -128,21 +127,11 @@ fi MD5_COMMAND=$(echo ${MD5} | cut -d' ' -f1) # basic tools - COMMANDS="cut sed wc wget xsltproc xargs rm mkdir chown comm grep date ${MD5_COMMAND}" + COMMANDS="cut sed wc wget xsltproc xargs rm mkdir chown comm egrep grep date ${MD5_COMMAND}" for COMMAND in ${COMMANDS} do [ "$(command -v "${COMMAND}")" ] || Err_Fatal "${COMMAND} doesn't exist in ${PATH}" done - - # grep checking - # originally created for workaround on solaris - #if [ `uname` = "SunOS" ]; then - FAIL= - echo "blah" > superrandomtestfile - echo "blah" > superrandomtestfile.2 - grep -f superrandomtestfile.2 superrandomtestfile > /dev/null 2>&1 || FAIL=1 - rm -f superrandomtestfile superrandomtestfile.2 - [ "${FAIL}" ] && Err_Fatal "Your grep is not compatible. Please install or set path of correct grep" } # verify required folders exist and writeable @@ -179,7 +168,7 @@ if [ -d "${TRASH}" ]; then ISTRASH=1 else - if [ "$(echo "${TRASH}" | sed -e "${SED_GET_FILENAME};${SED_IS_MD5_FILE}" | grep -v ^$)" ]; then + if [ "$(echo "${TRASH}" | sed -e "${SED_GET_FILENAME};${SED_IS_MD5_FILE}" | egrep -v ^$)" ]; then ISTRASH=1 else [ "$(cat "${TEMP_PREFIX}-list" | sed -e "${SED_GET_FILENAME}" | grep $(echo "${TRASH}" | sed -e "${SED_GET_FILENAME}"))" ] || ISTRASH=1 @@ -202,7 +191,7 @@ > "${TEMP_PREFIX}-error" for FILE in "${BASE_DIR}/${SITE_DIR}/${TARGET_DIR}/"* do - if [ "$(echo "${FILE}" | sed -e "${SED_GET_FILENAME};${SED_IS_MD5_FILE}" | grep -v ^$)" ]; then + if [ "$(echo "${FILE}" | sed -e "${SED_GET_FILENAME};${SED_IS_MD5_FILE}" | egrep -v ^$)" ]; then echo echo "Not a valid danbooru file: $(echo ${FILE} | sed -e "${SED_GET_FILENAME}")" else @@ -233,11 +222,11 @@ # find "${BASE_DIR}/${SITE_DIR}/${TARGET_DIR}" | comm -1 -3 "${TEMP_PREFIX}-error" - | sed -e "${SED_GET_FILENAME}" > "${TEMP_PREFIX}-ok" cat "${TEMP_PREFIX}-list" > "${TEMP_PREFIX}-templist" - while read -r IS_OK; do - cat "${TEMP_PREFIX}-templist" | grep -v "${IS_OK}" > "${TEMP_PREFIX}-newlist" - cat "${TEMP_PREFIX}-newlist" > "${TEMP_PREFIX}-templist" - done < "${TEMP_PREFIX}-ok" - #cat "${TEMP_PREFIX}-list" | grep -vf "${TEMP_PREFIX}-ok" > "${TEMP_PREFIX}-newlist" + #while read -r IS_OK; do + # cat "${TEMP_PREFIX}-templist" | grep -v "${IS_OK}" > "${TEMP_PREFIX}-newlist" + # cat "${TEMP_PREFIX}-newlist" > "${TEMP_PREFIX}-templist" + #done < "${TEMP_PREFIX}-ok" + cat "${TEMP_PREFIX}-list" | egrep -vf "${TEMP_PREFIX}-ok" > "${TEMP_PREFIX}-newlist" echo "$(echo $(wc -l < "${TEMP_PREFIX}-newlist")) file(s) to be downloaded" else