git.shiar.nl
/
barcat.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
b04f42d
)
minor code cleanup for human formatting
author
Mischa POSLAWSKY
<perl@shiar.org>
Sat, 7 Sep 2019 18:36:44 +0000
(20:36 +0200)
committer
Mischa POSLAWSKY
<perl@shiar.org>
Sun, 8 Sep 2019 13:57:09 +0000
(15:57 +0200)
barcat
patch
|
blob
|
history
diff --git
a/barcat
b/barcat
index 40f332d980ed308a3b41b45a161a662e5af63bf9..00a21739671c0a4d00df95517912299cdd472757 100755
(executable)
--- a/
barcat
+++ b/
barcat
@@
-56,7
+56,7
@@
GetOptions(\%opt,
$opt{width} ||= $ENV{COLUMNS} || 80;
$opt{color} //= -t *STDOUT; # enable on tty
$opt{trim} *= $opt{width} / 100 if $opt{trimpct};
$opt{width} ||= $ENV{COLUMNS} || 80;
$opt{color} //= -t *STDOUT; # enable on tty
$opt{trim} *= $opt{width} / 100 if $opt{trimpct};
-$opt{units} =
$opt{'human-readable'} && ['', qw( k M G T P E Z Y y z a f p n μ m )]
;
+$opt{units} =
[split //, ' kMGTPEZYyzafpnμm'] if $opt{'human-readable'}
;
$opt{anchor} //= qr/\A/;
$opt{'value-length'} = 6 if $opt{units};
$opt{anchor} //= qr/\A/;
$opt{'value-length'} = 6 if $opt{units};
@@
-136,7
+136,7
@@
sub sival {
sprintf('%*.*f%*s',
$float ? 5 : 3, $float, # length and tenths
$_[0] / 1000 ** $unit, # number
sprintf('%*.*f%*s',
$float ? 5 : 3, $float, # length and tenths
$_[0] / 1000 ** $unit, # number
- $float ?
1
: 3, # unit size
+ $float ?
0
: 3, # unit size
$#{$opt{units}} >> 1 < abs $unit ? "e$unit" : $opt{units}->[$unit]
);
}
$#{$opt{units}} >> 1 < abs $unit ? "e$unit" : $opt{units}->[$unit]
);
}