| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
############################################################################## |
| 4 |
# This is essentially a Perl program. We exec the Perl interpreter specifying |
| 5 |
# this same file as the Perl program and use the -x option to cause the Perl |
| 6 |
# interpreter to skip down to the Perl code. The reason we do this instead of |
| 7 |
# just making /usr/bin/perl the script interpreter (instead of /bin/sh) is |
| 8 |
# that the user may have multiple Perl interpreters and the one he wants to |
| 9 |
# use is properly located in the PATH. The user's choice of Perl interpreter |
| 10 |
# may be crucial, such as when the user also has a PERL5LIB environment |
| 11 |
# variable and it selects modules that work with only a certain main |
| 12 |
# interpreter program. |
| 13 |
# |
| 14 |
# An alternative some people use is to have /usr/bin/env as the script |
| 15 |
# interpreter. We don't do that because we think the existence and |
| 16 |
# compatibility of /bin/sh is more reliable. |
| 17 |
# |
| 18 |
# Note that we aren't concerned about efficiency because the user who needs |
| 19 |
# high efficiency can use directly the programs that this program invokes. |
| 20 |
# |
| 21 |
############################################################################## |
| 22 |
|
| 23 |
exec perl -w -x -S -- "$0" "$@" |
| 24 |
|
| 25 |
#! /usr/bin/perl |
| 26 |
|
| 27 |
#============================================================================ |
| 28 |
# This is a compatibility interface to Pbmtoxbm. |
| 29 |
# |
| 30 |
# It exists so existing programs and procedures that rely on Pbmtox10bm |
| 31 |
# syntax continue to work. You should not make new use of Pbmtox10bm and |
| 32 |
# if you modify an old use, you should upgrade it to use Pbmtoxbm. |
| 33 |
# |
| 34 |
# Pbmtoxbm with the -x10 option is backward compatible with Pbmtox10bm. |
| 35 |
#============================================================================ |
| 36 |
|
| 37 |
use strict; |
| 38 |
use File::Basename; |
| 39 |
use Cwd 'abs_path'; |
| 40 |
use IO::Handle; |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
sub pm_message($) { |
| 45 |
STDERR->print("pbmtox10bm: $_[0]\n"); |
| 46 |
} |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
sub doVersionHack($) { |
| 52 |
my ($argvR) = @_; |
| 53 |
|
| 54 |
my $arg1 = $argvR->[0]; |
| 55 |
|
| 56 |
if (defined($arg1) && (($arg1 eq "--version") || ($arg1 eq "-version"))) { |
| 57 |
my $termStatus = system('pbmtoxbm', '--version'); |
| 58 |
exit($termStatus == 0 ? 0 : 1); |
| 59 |
} |
| 60 |
} |
| 61 |
|
| 62 |
doVersionHack(\@ARGV); |
| 63 |
|
| 64 |
my $infile; |
| 65 |
|
| 66 |
foreach (@ARGV) { |
| 67 |
if (/^-/) { |
| 68 |
# It's an option. But Pbmtox10bm didn't have any options. |
| 69 |
pm_message("Invalid option '$_'"); |
| 70 |
exit(10); |
| 71 |
} else { |
| 72 |
# It's a parameter |
| 73 |
if (defined($infile)) { |
| 74 |
pm_message("You may specify at most one non-option parameter."); |
| 75 |
exit(10); |
| 76 |
} else { |
| 77 |
$infile = $_; |
| 78 |
} |
| 79 |
} |
| 80 |
} |
| 81 |
|
| 82 |
my $infileParm = defined($infile) ? $infile : "-"; |
| 83 |
|
| 84 |
# We want to get Pbmtoxbm from the same directory we came from if |
| 85 |
# it's there. Frequently, the directory containing Netpbm programs is |
| 86 |
# not in the PATH and we were invoked by absolute path. |
| 87 |
|
| 88 |
my $my_directory = abs_path(dirname($0)); |
| 89 |
$ENV{"PATH"} = $my_directory . ":" . $ENV{"PATH"}; |
| 90 |
|
| 91 |
exec('pbmtoxbm', '-x10', $infileParm); |