Debian Codegraph @

ex20.sh

raw symbols SCIP
1 #!/bin/bash
2
3 func1 ()
4 {
5 echo This is a function.
6 }
7
8 declare -f # Lists the function above.
9
10 echo
11
12 declare -i var1 # var1 is an integer.
13 var1=2367
14 echo "var1 declared as $var1"
15 var1=var1+1 # Integer declaration eliminates the need for 'let'.
16 echo "var1 incremented by 1 is $var1."
17 # Attempt to change variable declared as integer.
18 echo "Attempting to change var1 to floating point value, 2367.1."
19 var1=2367.1 # Results in error message, with no change to variable.
20 echo "var1 is still $var1"
21
22 echo
23
24 declare -r var2=13.36 # 'declare' permits setting a variable property
25 #+ and simultaneously assigning it a value.
26 echo "var2 declared as $var2" # Attempt to change readonly variable.
27 var2=13.37 # Generates error message, and exit from script.
28
29 echo "var2 is still $var2" # This line will not execute.
30
31 exit 0 # Script will not exit here.