PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : [BASH] integer expression expected



undefined
05-10-2005, 09:16
Morjen, Ich bekomme bei einem SuSE Script eine Fehler meldung die ich nicht ganz verstehe.
Ausschnitt:

#
# The main system printer.
#
lp=""
if test -x /usr/bin/lpoptions ; then
dev=PS
size=a4
dpi=300
color=mono
shopt -s extglob
while read -t 10 line ; do
case "$line" in
PageSize*)
set -- $line
while test -n "$1" ; do
case "$1" in
\**) size="${1:1}"; break
esac
shift
done
;;
Resolution*)
set -- $line
reg='+([0-9]|+([0-9])x([0-9]))*'
cur=0
while test -n "$1" ; do
case "$1" in
$reg) cur=${1%%+([[:alpha:]])}
esac
case "$1" in
*Color*) color=color
esac
shift
### Das hier ist die Relevante Zeile ###
test "${cur%x*}" -gt "${dpi%x*}" && dpi=$cur
echo "# $cur => ${cur%x*} # $dpi => ${dpi%x*} #"
done
;;
ColorCorrection*)
set -- $line
while test -n "$1" ; do
case "$1" in
\*RGB|\*CMYK) color=color; break
esac
shift
done
;;
esac
done < <(lpoptions -l 2> /dev/null)
shopt -u extglob
lp="lp|${dev}-$(echo ${size}-auto-${color}-${dpi}|tr '[:upper:]' '[:lower:]')"
elif test -r /etc/printcap -a -d /var/lib/apsfilter/ ; then
lp=$(grep -E '^lp\|' /etc/printcap)
elif test -r /etc/printcap -a -x /usr/lib/lpdfilter/bin/readpc ; then
lp=$(/usr/lib/lpdfilter/bin/readpc lp || true)
fi
test -n "$lp" || exit 0 # No (configured) filter system: nothing to do


Wenn ich SuSEconfig Ausführe bekomme ich nun diese Meldung.


Executing /sbin/conf.d/SuSEconfig.tetex...
# 0 => 0 # 300 => 300 #
# 0 => 0 # 300 => 300 #
# 300x300 => 300 # 300 => 300 #
# 300x300 => 300 # 300 => 300 #
/sbin/conf.d/SuSEconfig.tetex: line 136: test: 600x600: integer expression expected
# 600x600x1 => 600x600 # 300 => 300 #
/sbin/conf.d/SuSEconfig.tetex: line 136: test: 600x600: integer expression expected
# 600x600x2 => 600x600 # 300 => 300 #

Offensichtlich liegt es an diesem Syntax der mir aber unbekannt ist.

${cur%x*}
Weil ich statt einem x zwei bekomme.
Meine Frage ist wie dieser Syntax funktioniert?
mfg undefined

[EDIT]
Diese zeile wird uebergeben:
Resolution/Print Quality: 300x300dpi *600x600dpi 600x600x1dpi 600x600x2dpi

undefined
05-10-2005, 09:54
Ich habe das Problem jetzt auf diese Weise gelöst bin mir aber nicht sicher ob das so Richtig ist :rolleyes:


#
# The main system printer.
#
# @test SuSEconfig --module tetex
# @modified 2005-10-05
# FIXME Regexp didn't Pattern these String
# Resolution/Print Quality: 300x300dpi *600x600dpi 600x600x1dpi 600x600x2dpi
# @old cur=${1%%+([[:alpha:]])}
# @new cur=${1%%+([[:alpha:]])+([[:alnum:]][[:alpha:]])}
lp=""
if test -x /usr/bin/lpoptions ; then
dev=PS
size=a4
dpi=300
color=mono
shopt -s extglob
while read -t 10 line ; do
case "$line" in
PageSize*)
set -- $line
while test -n "$1" ; do
case "$1" in
\**) size="${1:1}"; break
esac
shift
done
;;
Resolution*)
set -- $line
reg='+([0-9]|+([0-9])x([0-9]))*'
cur=0
while test -n "$1" ; do
case "$1" in
$reg) cur=${1%%+([[:alpha:]])+([[:alnum:]][[:alpha:]])}
esac
case "$1" in
*Color*) color=color
esac
shift
test "${cur%x*}" -gt "${dpi%x*}" && dpi=$cur
done
;;
ColorCorrection*)
set -- $line
while test -n "$1" ; do
case "$1" in
\*RGB|\*CMYK) color=color; break
esac
shift
done
;;
esac
done < <(lpoptions -l 2> /dev/null)
shopt -u extglob
lp="lp|${dev}-$(echo ${size}-auto-${color}-${dpi}|tr '[:upper:]' '[:lower:]')"
elif test -r /etc/printcap -a -d /var/lib/apsfilter/ ; then
lp=$(grep -E '^lp\|' /etc/printcap)
elif test -r /etc/printcap -a -x /usr/lib/lpdfilter/bin/readpc ; then
lp=$(/usr/lib/lpdfilter/bin/readpc lp || true)
fi
test -n "$lp" || exit 0 # No (configured) filter system: nothing to do

Ein Info wäre nicht schlecht ob ich das so lassen kann ;)