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