Last change
on this file since 82 was
82,
checked in by rosiere, 16 years ago
|
- support locale (now must "just" translate)
- update all component with new test format
- update all component with usage
- New component : decod queue and prediction_unit
|
-
Property svn:keywords set to
Id
|
File size:
1.4 KB
|
Rev | Line | |
---|
[2] | 1 | #!/bin/sh |
---|
[82] | 2 | #----------------------------------------------------------- |
---|
| 3 | # $Id: range.sh 82 2008-05-01 16:48:45Z rosiere $ |
---|
| 4 | #----------------------------------------------------------- |
---|
[2] | 5 | |
---|
| 6 | #-----[ usage ]--------------------------------------------- |
---|
| 7 | function usage () |
---|
| 8 | { |
---|
[78] | 9 | echo "Usage : ${0} min max [step [iter]]"; |
---|
| 10 | echo "Arguments : "; |
---|
[2] | 11 | echo " * min : value minimal"; |
---|
| 12 | echo " * max : value maximal"; |
---|
| 13 | echo " * step : step between two value. If no present, step = \"+1\""; |
---|
| 14 | echo " * iter : choose the Nième value"; |
---|
| 15 | exit; |
---|
| 16 | } |
---|
| 17 | |
---|
| 18 | #-----[ range ]--------------------------------------------- |
---|
| 19 | function range () |
---|
| 20 | { |
---|
[78] | 21 | declare a=${1}; |
---|
| 22 | declare b=${2}; |
---|
| 23 | declare step=${3}; |
---|
[2] | 24 | |
---|
[78] | 25 | while test ${a} -lt ${b}; do |
---|
| 26 | echo ${a}; |
---|
| 27 | a=$((${a} ${step})); |
---|
[57] | 28 | done |
---|
| 29 | |
---|
[78] | 30 | if test ${a} -eq ${b}; then |
---|
| 31 | echo ${a}; |
---|
[57] | 32 | fi; |
---|
[2] | 33 | } |
---|
| 34 | |
---|
| 35 | #-----[ range_max ]----------------------------------------- |
---|
| 36 | function range_max () |
---|
| 37 | { |
---|
[78] | 38 | declare a=${1}; |
---|
| 39 | declare b=${2}; |
---|
| 40 | declare step=${3}; |
---|
| 41 | declare iter=${4}; |
---|
[2] | 42 | |
---|
[78] | 43 | while test ${a} -lt ${b} -a ${iter} -gt 1; do |
---|
| 44 | a=$((${a} ${step})); |
---|
| 45 | iter=$((${iter}-1)); |
---|
[2] | 46 | done; |
---|
| 47 | |
---|
[78] | 48 | if test ${a} -eq ${b}; then |
---|
| 49 | echo ${a}; |
---|
[57] | 50 | fi; |
---|
| 51 | |
---|
[78] | 52 | if test ${iter} -eq 1; then |
---|
| 53 | echo ${a}; |
---|
[2] | 54 | fi; |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | #-----[ main ]---------------------------------------------- |
---|
| 58 | function main () |
---|
| 59 | { |
---|
| 60 | # create operande |
---|
[78] | 61 | case ${#} in |
---|
| 62 | 2) range ${*} "+1";; |
---|
| 63 | 3) range ${*} ;; |
---|
| 64 | 4) range_max ${*} ;; |
---|
| 65 | *) usage ${*} |
---|
[2] | 66 | esac |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | #-----[ Corps ]--------------------------------------------- |
---|
[78] | 70 | main ${*} |
---|
Note: See
TracBrowser
for help on using the repository browser.