| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | |
| 3 | func1scip-shell shell abs-guide 10-4 func1(). () |
| 4 | { |
| 5 | echoscip-shell system . . echo. This is a function. |
| 6 | } |
| 7 | |
| 8 | declare -f # Lists the function above. |
| 9 | |
| 10 | echoscip-shell system . . echo. |
| 11 | |
| 12 | declare -i var1 # var1 is an integer. |
| 13 | var1=2367 |
| 14 | echoscip-shell system . . echo. "var1 declared as $var1" |
| 15 | var1=var1+1 # Integer declaration eliminates the need for 'let'. |
| 16 | echoscip-shell system . . echo. "var1 incremented by 1 is $var1." |
| 17 | # Attempt to change variable declared as integer. |
| 18 | echoscip-shell system . . 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 | echoscip-shell system . . echo. "var1 is still $var1" |
| 21 | |
| 22 | echoscip-shell system . . echo. |
| 23 | |
| 24 | declare -r var2=13.36 # 'declare' permits setting a variable property |
| 25 | #+ and simultaneously assigning it a value. |
| 26 | echoscip-shell system . . echo. "var2 declared as $var2" # Attempt to change readonly variable. |
| 27 | var2=13.37 # Generates error message, and exit from script. |
| 28 | |
| 29 | echoscip-shell system . . echo. "var2 is still $var2" # This line will not execute. |
| 30 | |
| 31 | exit 0 # Script will not exit here. |