| Next | System Programming in Perl | 21 |
In fact, the cd 'command' is not a command at all
There is no /bin/cd
cd must always be implemented as a shell built-in command
%builtin = (cd => sub { chdir $_[0]
|| warn "Couldn't chdir to $_[0]: $!\n"; },
exit => sub { exit $_[0] || 0 },
);
while (1) {
print "perl% ";
my $command = <STDIN>;
last if $command eq '';
chomp $command;
my (%command) = parse($command);
if (defined $builtin{$command{program}}) {
$builtin{$command{program}}->(@{$command{args}});
next;
}
...
}
| Next | ![]() |
Copyright © 2003 M. J. Dominus |