2
# Create and remove directories and check their existence
2
# Perform simple file and directory manipulation in a portable way
5
print "Usage: $0 mkdir|rmdir|gone path\n";
5
print "Usage: $0 mkdir|rmdir|rm|move|gone path1 [path2] [more commands...]\n";
8
if ($ARGV[0] eq "mkdir")
10
mkdir $ARGV[1] || die "$!";
13
elsif ($ARGV[0] eq "rmdir")
15
rmdir $ARGV[1] || die "$!";
18
elsif ($ARGV[0] eq "gone")
20
! -e $ARGV[1] || die "Path $ARGV[1] exists";
23
print "Unsupported command $ARGV[0]\n";
11
my $cmd = shift @ARGV;
12
my $arg = shift @ARGV;
13
if ($cmd eq "mkdir") {
14
mkdir $arg || die "$!";
16
elsif ($cmd eq "rmdir") {
17
rmdir $arg || die "$!";
19
elsif ($cmd eq "rm") {
20
unlink $arg || die "$!";
22
elsif ($cmd eq "move") {
23
my $arg2 = shift @ARGV;
24
move($arg,$arg2) || die "$!";
26
elsif ($cmd eq "gone") {
27
! -e $arg || die "Path $arg exists";
29
print "Unsupported command $cmd\n";