| 1 |
#!/usr/bin/env perl |
| 2 |
|
| 3 |
use strict; |
| 4 |
use warnings; |
| 5 |
use Getopt::Declare; |
| 6 |
|
| 7 |
my $shell_cmds = <<'EOCMDS'; |
| 8 |
Commands: [repeatable] |
| 9 |
|
| 10 |
echo [-n] <words:/.*/> ECHO WITHOUT NEWLINE |
| 11 |
{ print $words; print "\n" unless $_PUNCT_{'-n'}; } |
| 12 |
|
| 13 |
[pvtype: chwho /u?g?a?/] |
| 14 |
[pvtype: chwhat /r?w?x?/] |
| 15 |
|
| 16 |
chmod [-R] <who:chwho>=<what:chwhat> <files>... |
| 17 |
CHANGE FILE PERMISSIONS |
| 18 |
{ foreach (@files) { print "chmod $who=$what $_\n"; } } |
| 19 |
|
| 20 |
help SHOW THIS SUMMARY |
| 21 |
{ $self->usage() } |
| 22 |
|
| 23 |
exit EXIT SHELL |
| 24 |
{ exit } |
| 25 |
|
| 26 |
<error:/.*/> |
| 27 |
{ print "Unknown command: $error\n"; |
| 28 |
print "(Try the 'help' command?)\n"; } |
| 29 |
EOCMDS |
| 30 |
|
| 31 |
my $shell = Getopt::Declare->new($shell_cmds,[-BUILD]); |
| 32 |
|
| 33 |
my $count = 1; |
| 34 |
sub prompt { print "$count> "; $count++; return <STDIN> } |
| 35 |
|
| 36 |
print "Welcome to an interactive shell!\n"; |
| 37 |
$shell->parse(\&prompt); |