Last change
on this file since 135 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
|
Line | |
---|
1 | #!/bin/bash |
---|
2 | |
---|
3 | #----------------------------------------------------------- |
---|
4 | # $Id: range.sh 85 2008-05-14 13:09:48Z rosiere $ |
---|
5 | #----------------------------------------------------------- |
---|
6 | |
---|
7 | #-----[ usage ]--------------------------------------------- |
---|
8 | function usage () |
---|
9 | { |
---|
10 | echo "Usage : ${0} min max [step [iter]]"; |
---|
11 | echo "Arguments : "; |
---|
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 | { |
---|
22 | declare a=${1}; |
---|
23 | declare b=${2}; |
---|
24 | declare step=${3}; |
---|
25 | |
---|
26 | while test ${a} -lt ${b}; do |
---|
27 | echo ${a}; |
---|
28 | a=$((${a} ${step})); |
---|
29 | done |
---|
30 | |
---|
31 | if test ${a} -eq ${b}; then |
---|
32 | echo ${a}; |
---|
33 | fi; |
---|
34 | } |
---|
35 | |
---|
36 | #-----[ range_max ]----------------------------------------- |
---|
37 | function range_max () |
---|
38 | { |
---|
39 | declare a=${1}; |
---|
40 | declare b=${2}; |
---|
41 | declare step=${3}; |
---|
42 | declare iter=${4}; |
---|
43 | |
---|
44 | while test ${a} -lt ${b} -a ${iter} -gt 1; do |
---|
45 | a=$((${a} ${step})); |
---|
46 | iter=$((${iter}-1)); |
---|
47 | done; |
---|
48 | |
---|
49 | if test ${a} -eq ${b}; then |
---|
50 | echo ${a}; |
---|
51 | fi; |
---|
52 | |
---|
53 | if test ${iter} -eq 1; then |
---|
54 | echo ${a}; |
---|
55 | fi; |
---|
56 | } |
---|
57 | |
---|
58 | #-----[ main ]---------------------------------------------- |
---|
59 | function main () |
---|
60 | { |
---|
61 | # create operande |
---|
62 | case ${#} in |
---|
63 | 2) range ${*} "+1";; |
---|
64 | 3) range ${*} ;; |
---|
65 | 4) range_max ${*} ;; |
---|
66 | *) usage ${*} |
---|
67 | esac |
---|
68 | } |
---|
69 | |
---|
70 | #-----[ Corps ]--------------------------------------------- |
---|
71 | main ${*} |
---|
Note: See
TracBrowser
for help on using the repository browser.