Add PATH command lookup and improve command handling logic
This commit is contained in:
parent
3b6dffa176
commit
9204a8f519
2 changed files with 25 additions and 13 deletions
21
pshell.pl
21
pshell.pl
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue