Use $(..) instead of deprecated `..`
Use return instead of break in special opt processing function
minor indentation issue
make sure exit  always gets called if exec is called
Move the whole script into a main function
move platform identification into a function