I have been programming in BASH for a while now and the scripts that I write are starting to get more complicated.
I realized that I started to bring in some habits from C/C++ and wanted to get confirmation on if I needed to break my current habits or not. The reason being, not all programming languages are the same and they should be used to capitalize on their strengths.
Using Variables
function()
{
#declaration block
runCommand=
for string in "$@"; do
runCommand="$runCommand $string"
done
}
vs
function()
{
for string in "$@"; do
runCommand="$runCommand $string"
done
}
Which is advised for BASH/SH and for what reasons?
I have currently referred to the following websites.
http://lug.fh-swf.de/vim/vim-bash/StyleGuideShell.en.pdf
https://stackoverflow.com/questions/15610794/bash-coding-conventions
http://wiki.bash-hackers.org/scripting/style
Edit: My question was a little unclear so I changed the code example a little bit.