This refactoring includes the following changes:
- Introduce separate functions to analyze a core dump using sh(1) commands and kgdb(1) commands which can be later used for user-defined commands;
- Introduce main() function to declare variables used only for parsing arguments and preparing a core summary as local;
- Declare global variables at the top of the script;
- Reduce a scope of variables within functions to the local scope.
As a result of the refactoring, disallow to pass empty flag arguments or use the -d flag with an explicit vmcore.