how do you use brackets ?? in a script.

:smiley: i am pretty much new to scripting and don't want to pick up bad habits so I am trying to get myself to use brackets in my scripts since I plan on using them alot.. !
in this example of a script I wrote I can not figure out where the brackets go can anyone give me some insight into the use of brackets..??

# !/bin/sh
# .clear
TTY=`tty`
function fun { clear; pwd; date; tty; }
echo "enter term:"
read term
if [ "$TTY" == "/dev/pts/$term" ]
then
fun
echo "experimental terminal" > /dev/pts/$term
elif [ "$term" == "z" ]
then
fun
ls -ali -R . | less > /dev/tty
else
fun
while [ "$term" == "a" ]
do
fun
echo "//usbterminal//" > /dev/tty
break;
done
fi

I am taking scripting seriously and have managed to get this far on my own with a few suggestions from unix.com.. I would really like to understand the theory behind brackets.. :rolleyes:

thanx moxxx68

:slight_smile: in the script I am comfortable with the barckets around the test conditions and so on.. but as far as the brackets that go around the if then fi blocks and so on, i am not sure where to place them.. I have some general idea from studying c programming.. but i am not having the same success with brackets in shells as I am having with c programming.. an example would help...
thanx moxxx68:confused:
ps.. please use previous example so i can get some rough idea of what i am doing wrong..

Most programming lanugages allow for brackets or parentheses for clarification purposes...

But they are usu not required by many languages. Be careful when using parenthesis too often, as you might become confused and have an odd one which will cause much hairpulling on your part to debug.

Many "shell" languages dont use braces or parenthesis, they use the logic structure to open and close logic statements...

if

fi

case

esac

if
then
elseif
fi
fi

:smiley: infact after looking through a few posts on the sites I didn't see the use of braces in a script so i figured you can do without them, but Jim a senior member gave me an example of a script in good logic form where he used braces. and since what I wrote was close and not working because of set up, he suggested to use better format.. at the time it looked a little difficult to even set up the gawk script in # !/bin/sh format like he did without the braces.!! but if braces are not considered completely necessry all the better..
thanx a million for your input moxxx68:)