]> git.alsa-project.org Git - alsa-utils.git/commitdiff
alsa-info: Don't try update when wget isn't available
authorTakashi Iwai <tiwai@suse.de>
Mon, 27 Apr 2015 19:27:05 +0000 (21:27 +0200)
committerTakashi Iwai <tiwai@suse.de>
Mon, 27 Apr 2015 19:29:06 +0000 (21:29 +0200)
... otherwise it overwrites a zero size file.  Also add a check of
zero size file in the update procedure, too.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
alsa-info/alsa-info.sh

index acd849588141232ae5d6d258d498fa0b7ff4d8cf..0bc4cd0612fb37e05712f446141a2a5cafd8a458 100755 (executable)
@@ -35,6 +35,8 @@ BGTITLE="ALSA-Info v $SCRIPT_VERSION"
 PASTEBINKEY="C9cRIO8m/9y8Cs0nVs0FraRx7U0pHsuc"
 #Define some simple functions
 
+WGET=$(which wget 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null)
+
 pbcheck(){
        [[ $UPLOAD = "no" ]] && return
 
@@ -46,10 +48,12 @@ pbcheck(){
 }
 
 update() {
+       test -z "$WGET" -o ! -x "$WGET" && return
+
        SHFILE=`mktemp -t alsa-info.XXXXXXXXXX` || exit 1
        wget -O $SHFILE "http://www.alsa-project.org/alsa-info.sh" >/dev/null 2>&1
        REMOTE_VERSION=`grep SCRIPT_VERSION $SHFILE |head -n1 |sed 's/.*=//'`
-       if [ "$REMOTE_VERSION" != "$SCRIPT_VERSION" ]; then
+       if [ -s "$SHFILE" -a "$REMOTE_VERSION" != "$SCRIPT_VERSION" ]; then
                if [[ -n $DIALOG ]]
                then
                        OVERWRITE=
@@ -831,8 +835,7 @@ if [ "$UPLOAD" = "no" ]; then
 fi # UPLOAD
 
 #Test that wget is installed, and supports --post-file. Upload $FILE if it does, and prompt user to upload file if it doesnt. 
-if
-WGET=$(which wget 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null); [[ -n "${WGET}" ]] && [[ -x "${WGET}" ]] && [[ `wget --help |grep post-file` ]]
+if [[ -n "${WGET}" ]] && [[ -x "${WGET}" ]] && [[ `wget --help |grep post-file` ]]
 then
 
 if [[ -n $DIALOG ]]