FIX output catching and presence testing
[summon-arm-toolchain.git] / summon-arm-toolchain
index 9577702c3e5e41a91fd46c362282a3f859ac28e3..5706b8135c2fd8e193d6c5f8b61e6da1d3d44a5d 100755 (executable)
@@ -72,9 +72,9 @@ b2269d30ce7b93b7c714b90ef2f40221c2df0fcd  newlib-1.19.0.tar.gz"
 # Flags section
 ##############################################################################
 
-if which getconf > /dev/null && getconf _NPROCESSORS_ONLN > /dev/null; then
+if which getconf > /dev/null 2> /dev/null && getconf _NPROCESSORS_ONLN > /dev/null 2> /dev/null; then
        CPUS=$(getconf _NPROCESSORS_ONLN)
-elif which sysctl > /dev/null && sysctl hw.ncpu > /dev/null; then
+elif which sysctl > /dev/null 2> /dev/null && sysctl hw.ncpu 2> /dev/null > /dev/null; then
   CPUS=$(sysctl hw.ncpu | sed -E -e 's/^hw\.ncpu(: | = )//')
 else
        CPUS=1
@@ -147,7 +147,7 @@ fi
 ##############################################################################
 
 # Fetch a versioned file from a URL
-fetch() {
+dofetch() {
     if [ ! -e ${STAMPS}/$1.fetch ]; then
         log "Downloading $1 sources..."
         ${FETCHCMD} $2
@@ -201,13 +201,13 @@ mkdir -p ${STAMPS} ${SOURCES}
 
 cd ${SOURCES}
 
-fetch ${BINUTILS} http://ftp.gnu.org/gnu/binutils/${BINUTILS}.tar.bz2
-fetch ${GCC} ${GCCURL}
-fetch ${NEWLIB} ftp://sources.redhat.com/pub/newlib/${NEWLIB}.tar.gz
-fetch ${GDB} http://ftp.gnu.org/gnu/gdb/${GDB}.tar.bz2
-fetch ${GMP} ftp://ftp.gmplib.org/pub/${GMP}/${GMP}.tar.bz2
-fetch ${MPFR} http://www.mpfr.org/${MPFR}/${MPFR}.tar.bz2
-fetch ${MPC} http://www.multiprecision.org/mpc/download/${MPC}.tar.gz
+dofetch ${BINUTILS} http://ftp.gnu.org/gnu/binutils/${BINUTILS}.tar.bz2
+dofetch ${GCC} ${GCCURL}
+dofetch ${NEWLIB} ftp://sources.redhat.com/pub/newlib/${NEWLIB}.tar.gz
+dofetch ${GDB} http://ftp.gnu.org/gnu/gdb/${GDB}.tar.bz2
+dofetch ${GMP} ftp://ftp.gmplib.org/pub/${GMP}/${GMP}.tar.bz2
+dofetch ${MPFR} http://www.mpfr.org/${MPFR}/${MPFR}.tar.bz2
+dofetch ${MPC} http://www.multiprecision.org/mpc/download/${MPC}.tar.gz
 
 if which sha1sum > /dev/null; then
     for f in ${BINUTILS} ${GCC} ${NEWLIB} ${GDB} ${GMP} ${MPFR} ${MPC}; do