git.shiar.nl
/
sheet.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
3edd299
)
font: mkttfinfo: no glob; exit codes
author
Mischa POSLAWSKY
<perl@shiar.org>
Sat, 7 Mar 2015 22:00:39 +0000
(23:00 +0100)
committer
Mischa POSLAWSKY
<perl@shiar.org>
Tue, 9 Jun 2015 03:43:43 +0000
(
05:43
+0200)
tools/mkttfinfo
patch
|
blob
|
history
diff --git
a/tools/mkttfinfo
b/tools/mkttfinfo
index bbafece3e8a27688f300ea03c26de357cb4bc69a..72564bffa9e656f16103fa91d4ef285a0d484291 100755
(executable)
--- a/
tools/mkttfinfo
+++ b/
tools/mkttfinfo
@@
-8,23
+8,21
@@
use Font::TTF::Font;
use Getopt::Long;
use Cwd 'abs_path';
use Getopt::Long;
use Cwd 'abs_path';
-our $VERSION = '1.0
0
';
+our $VERSION = '1.0
1
';
GetOptions(\my %opt,
'verbose|v!',
);
my ($ttfuri, $outfile) = @ARGV;
GetOptions(\my %opt,
'verbose|v!',
);
my ($ttfuri, $outfile) = @ARGV;
-$ttfuri or die "usage error\n";
-
-my $fontinc = $ENV{FONTINC} // 'data/font,~/.fonts,/usr/share/fonts/truetype/*';
-if (!-e $ttfuri) {
- my $found = (grep {-e} glob "{$fontinc}/$ttfuri")[0] or do {
- warn "font not found: $ttfuri\n";
- exit 1;
- };
- $ttfuri = $found;
-}
+$ttfuri or do {
+ warn "usage error: input font not specified\n";
+ exit 64; # EX_USAGE
+};
+-e $ttfuri or do {
+ warn "font not found: $ttfuri\n";
+ exit 66; # EX_NOINPUT
+};
for ($outfile || ()) {
open my $output, '>', $_ or die "Cannot write to $outfile: $!\n";
for ($outfile || ()) {
open my $output, '>', $_ or die "Cannot write to $outfile: $!\n";
@@
-32,8
+30,10
@@
for ($outfile || ()) {
}
{
}
{
- my $ttf = Font::TTF::Font->open($ttfuri)
- or die "Cannot open truetype in $ttfuri: $!";
+ my $ttf = Font::TTF::Font->open($ttfuri) or do {
+ warn "Cannot open truetype in $ttfuri: $!";
+ exit 65; # EX_DATAERR
+ };
my $ttfname = ($ttfuri =~ m{([^/.]+) (?:[.]ttf)? \z}msx)[0];
my $ttfmeta = $ttf->{name}->read;
my $ttfname = ($ttfuri =~ m{([^/.]+) (?:[.]ttf)? \z}msx)[0];
my $ttfmeta = $ttf->{name}->read;