Article 5E768 Pros/cons of declare variable in bash

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?

Thankslatest?d=yIl2AUoC8zA latest?i=AM6rMA-44N0:Cpt9hsYZaVo:F7zBnMy latest?i=AM6rMA-44N0:Cpt9hsYZaVo:V_sGLiP latest?d=qj6IDK7rITs latest?i=AM6rMA-44N0:Cpt9hsYZaVo:gIN9vFwAM6rMA-44N0
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments