On Mon, May 21, 2012 at 04:01:16PM -0500, David C. Rankin wrote:
Bash gurus,
Here is one I don't understand. I needed a simple script to part gtkrc and convert the r,g,b (0.0-1.0) values to (0-255). So I decided to use 'calc' to get the floating point values. The script was:
#!/bin/bash
while read l; do [[ $l =~ , ]] && [[ ${l:0:1} != [#] ]] && { rgb=${l##*[{] } rgb=${rgb%\ \}*} rgb=${rgb//,} r=${rgb%% *} g=${rgb% *} g=${g#* } b=${rgb##* } _r=$(calc -p "255 * $r") _g=$(calc -p "255 * $g") _b=$(calc -p "255 * $b") echo "${rgb} => r:$r g:$g b:$b => r:$_r g:$_g b:$_b"; } done < gtkrc-file.txt
The sample gtkrc file is included at the end of the message. Running the script resulted in the error:
15:38 providence:~/cnf/kde3> sh parsegtkrc.sh "bg" is undefined
I think this is just because "sh" is using the traditional shell behaviour and does hide the "bash" enhanced functionality. try bash parsegtkrc.sh Ciao, Marcus -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org