Pros/cons of declare variable in bash
by Arct1c_f0x from LinuxQuestions.org on (#5E768)
Consider the following script:
Code:#! /usr/bin/bash
declare -i H
declare -i M
echo -e "Set alarm hour value"
read H
echo -e "Set alarm minute value"
read M
echo "$H:$M"
What advantages are there to using the declare command to declare shell variables as opposed to just setting the variables with read. Note that in both cases the observable effect is the same. Is there something that I'm missing? Something that is going on behind the scenes? What advantages are there to either using the declare command or just initializing the variables with the read command?
Thanks


Code:#! /usr/bin/bash
declare -i H
declare -i M
echo -e "Set alarm hour value"
read H
echo -e "Set alarm minute value"
read M
echo "$H:$M"
What advantages are there to using the declare command to declare shell variables as opposed to just setting the variables with read. Note that in both cases the observable effect is the same. Is there something that I'm missing? Something that is going on behind the scenes? What advantages are there to either using the declare command or just initializing the variables with the read command?
Thanks