Fixing some style issues.

This commit is contained in:
Haitham Gad 2013-03-10 11:36:56 -04:00 committed by Paul Beckingham
parent 50d201a7f0
commit 881e4995e0
2 changed files with 19 additions and 21 deletions

View file

@ -63,7 +63,6 @@ int main (int argc, const char** argv)
srand (tv.tv_usec); srand (tv.tv_usec);
#endif #endif
int status = 0;
bool read_from_file = false; bool read_from_file = false;
if (argc > 2) if (argc > 2)
@ -85,9 +84,10 @@ int main (int argc, const char** argv)
} }
else else
{ {
// The user has give tasksh a task commands file to execute // The user has given tasksh a task commands file to execute
File input_file = File (argv[1]); File input_file = File (argv[1]);
if (!input_file.exists ()) { if (!input_file.exists ())
{
std::cout << STRING_SHELL_NO_FILE; std::cout << STRING_SHELL_NO_FILE;
std::cout << STRING_SHELL_USAGE << "\n"; std::cout << STRING_SHELL_USAGE << "\n";
return -1; return -1;
@ -99,7 +99,8 @@ int main (int argc, const char** argv)
// if a file is given, read from it // if a file is given, read from it
std::ifstream fin; std::ifstream fin;
if (read_from_file) { if (read_from_file)
{
fin.open (argv[1]); fin.open (argv[1]);
} }
@ -107,7 +108,7 @@ int main (int argc, const char** argv)
std::istream &in = read_from_file ? fin : std::cin; std::istream &in = read_from_file ? fin : std::cin;
// Begining initilaization // Begining initilaization
status = context.initialize (0, NULL); context.initialize (0, NULL);
// Display some kind of welcome message. // Display some kind of welcome message.
Color bold (Color::nocolor, Color::nocolor, false, true, false); Color bold (Color::nocolor, Color::nocolor, false, true, false);
@ -165,38 +166,35 @@ int main (int argc, const char** argv)
{ {
Wordexp w ("task " + trim (input + permanent_overrides)); Wordexp w ("task " + trim (input + permanent_overrides));
for (int i = 0; i < w.argc (); ++i) { for (int i = 0; i < w.argc (); ++i)
{
if (std::find (quit_commands.begin (), quit_commands.end (), if (std::find (quit_commands.begin (), quit_commands.end (),
lowerCase (w.argv ()[i])) != quit_commands.end ()) lowerCase (w.argv ()[i])) != quit_commands.end ())
{ {
context.clearMessages (); context.clearMessages ();
return status; return 0;
} }
} }
status = context.initialize (w.argc (), (const char**)w.argv ()); int status = context.initialize (w.argc (), (const char**)w.argv ());
if (status == 0) if (status == 0)
status = context.run (); context.run ();
} }
catch (const std::string& error) catch (const std::string& error)
{ {
std::cerr << error << "\n"; std::cerr << error << "\n";
status = -1; return -1;
break;
} }
catch (...) catch (...)
{ {
std::cerr << STRING_UNKNOWN_ERROR << "\n"; std::cerr << STRING_UNKNOWN_ERROR << "\n";
status = -2; return -2;
break;
} }
} }
// No need to repeat any overrides after the shell quits. return 0;
context.clearMessages ();
return status;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////