View Single Post
Old 08-25-2005, 09:52 PM   #4 (permalink)
teknomage1
Jack of all trades
 
teknomage1's Avatar
 
Join Date: Feb 2005
Location: Los Angeles
Posts: 598
teknomage1 is on a distinguished road
Send a message via AIM to teknomage1
I'm pretty sure the way a shell's top loop looks is like this
Code:
//psuedo code
read_input_line();
tokenize();
if (expandable)  //for aliases and history substitutions
{
  rewrite_exapandable_tokens();
}

//Compare the first token to a list of built in commands
foreach ( builtin in builtin_list ) {
 if ( command_token == builtin )
 {
   execute->command_token( parameter_tokens );
   break;
 }
}

//If that didn't work try executing it as a filesystem command
try_execute_file_in_path( command_token );

//Finally just fail
signal_error();
__________________
Stop intellectual property from infringing on me
teknomage1 is offline   Reply With Quote