-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathperlpowertools
executable file
·72 lines (59 loc) · 1.84 KB
/
perlpowertools
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env perl
#
# perlpowertools - helper script for PerlPowerTools
=begin metadata
Name: perlpowertools
Description: a program launcher for Perl Power Tools
Author: kal247, https://github.com/kal247
License: artistic2
=end metadata
=cut
use strict;
use warnings;
use utf8;
use Getopt::Std;
use File::Basename;
use Cwd 'abs_path';
our $VERSION = qw( 1.025 );
my $program = 'perlpowertools';
my @tools = qw( addbib apply ar arch arithmetic asa awk banner base64
basename bc bcd cal cat chgrp ching chmod chown clear cmp col colrm comm cp
cut date dc deroff diff dirname du echo ed env expand expr factor false file
find fish fmt fold fortune from glob grep hangman head hexdump id install
join kill ln lock look ls mail maze mimedecode mkdir mkfifo moo morse nl od
par paste patch perldoc pig ping pom ppt pr primes printenv printf pwd rain
random rev rm rmdir robots rot13 seq shar sleep sort spell split strings sum
tac tail tar tee test time touch tr true tsort tty uname unexpand uniq units
unlink unpar unshar uudecode uuencode wc what which whoami whois words wump
xargs yes );
my $usage = <<EOF;
Usage: $program [-hVl]
$program tool [arg ...]
-h, --help help
-V, --version version
-l list tools
EOF
# options
$Getopt::Std::STANDARD_HELP_VERSION = 1;
my %options = ();
getopts("hVl", \%options) or die $usage;
die $usage if $options{'h'};
if ($options{'V'}) {
print $VERSION, "\n";
exit;
}
if ($options{'l'}) {
print join ("\n", @tools), "\n";
exit;
}
########
# MAIN #
########
my $tool = shift || '';
die $usage if not grep { $tool eq $_ } @tools;
my $file = defined $ENV{PAR_TEMP} ? "$ENV{PAR_TEMP}/inc/script/$tool" : dirname(abs_path($0)) . "/$tool";
$0 = $tool; # for usage/warning/error messages
my $return = do $file;
die $@ if $@;
die "$file: $!" unless defined $return;
exit 1;