1#!/usr/bin/env perl
2# Perform simple file and directory manipulation in a portable way
3if ( $#ARGV <= 0 )
4{
5    print "Usage: $0 mkdir|rmdir|rm|move|gone path1 [path2] [more commands...]\n";
6    exit 1;
7}
8
9use File::Copy;
10while(@ARGV) {
11    my $cmd = shift @ARGV;
12    my $arg = shift @ARGV;
13    if ($cmd eq "mkdir") {
14        mkdir $arg || die "$!";
15    }
16    elsif ($cmd eq "rmdir") {
17        rmdir $arg || die "$!";
18    }
19    elsif ($cmd eq "rm") {
20        unlink $arg || die "$!";
21    }
22    elsif ($cmd eq "move") {
23        my $arg2 = shift @ARGV;
24        move($arg,$arg2) || die "$!";
25    }
26    elsif ($cmd eq "gone") {
27        ! -e $arg || die "Path $arg exists";
28    } else {
29        print "Unsupported command $cmd\n";
30        exit 1;
31    }
32}
33exit 0;
34