Bug 5505

Summary: alternatives-helper: interpreter errors on some unexpected input options
Product: Sisyphus Reporter: Ivan Zakharyaschev <imz>
Component: alternativesAssignee: placeholder <placeholder>
Status: CLOSED FIXED QA Contact: qa-sisyphus
Severity: minor    
Priority: P2 CC: at, glebfm, ldv, placeholder
Version: unstable   
Hardware: all   
OS: Linux   

Description Ivan Zakharyaschev 2004-11-15 02:33:28 MSK
alternatives-0.2.0-alt0.11

The script contains unquoted variable substitutions, which lead to errors on
unexpected options because the variables expand then to unsuitable values.

A workaround:

*** alternatives-helper	2004/11/14 23:12:31	1.1
--- alternatives-helper	2004/11/14 23:18:39	1.2
***************
*** 34,41 ****
  	    mode=2; shift; continue
  	fi
  
! 	[ $mode -eq 1 ] && alternatives-install $1
! 	[ $mode -eq 2 ] && alternatives-uninstall $1
  
  	shift
  done
--- 34,41 ----
  	    mode=2; shift; continue
  	fi
  
! 	[ "${mode:-0}" -eq 1 ] && alternatives-install "$1"
! 	[ "${mode:-0}" -eq 2 ] && alternatives-uninstall "$1"
  
  	shift
  done

Steps to Reproduce:
/usr/sbin/alternatives-helper -h

Actual Results:  
/usr/sbin/alternatives-helper: line 37: [: : integer expression expected
/usr/sbin/alternatives-helper: line 38: [: : integer expression expected


Expected Results:  
At least, no sh errors.
But would like to see a usage message.
Comment 1 Ivan Zakharyaschev 2004-11-15 02:39:34 MSK
No, actual actual results were:

# /usr/sbin/alternatives-helper -h
/usr/sbin/alternatives-helper: line 37: [: -eq: unary operator expected
/usr/sbin/alternatives-helper: line 38: [: -eq: unary operator expected

(What I pasted before were the results of the 1st work-around attempt.)
Comment 2 inger@altlinux.org 2004-11-18 12:56:07 MSK
Спасибо за замечания, патч обязательно приложу. 
 
Comment 3 inger@altlinux.org 2005-04-07 14:48:42 MSD
давно