Add PATH command lookup and improve command handling logic

This commit is contained in:
kake26 2025-04-15 16:32:48 -05:00
parent 3b6dffa176
commit 9204a8f519
Signed by: kake26
GPG key ID: E0A989B571D1F99F
2 changed files with 25 additions and 13 deletions

View file

@ -60,20 +60,17 @@ while (1) {
# Skip empty commands
next unless length $command;
# Try custom commands first
# Handle command
my $cmd_status = CustomCommands::handle($command, $env);
if ($cmd_status == 1) {
next;
}
elsif ($cmd_status == -1) {
print "Command not found: $command\n";
if ($cmd_status >= 0) { # 1=handled, 2=system command
# Save valid commands to history
$history->add($command);
$term->addhistory($command);
next;
}
# Save command to history
$history->add($command);
$term->addhistory($command);
# Execute command
system($command);
# Command not found
#print STDERR "DEBUG: Main program detected command not found\n";
print "Command not found: $command\n";
next;
}