alsa-info: Don't try update when wget isn't available

... 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>
This commit is contained in:
Takashi Iwai 2015-04-27 21:27:05 +02:00
parent f3abdeea00
commit 8188c2466a

View file

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