Skip to content

Commit 80abdf4

Browse files
authored
od: add -h alias for -x
* GNU and OpenBSD versions support either -h or -x for 2-byte hex, and -H/-X for 4-byte hex * This version had -X, -x and -H but not -h
1 parent 61b8f9f commit 80abdf4

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

bin/od

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ use constant LINESZ => 16;
2424
use constant PRINTMAX => 126;
2525

2626
use vars qw/ $opt_A $opt_a $opt_B $opt_b $opt_c $opt_d $opt_e $opt_F $opt_f
27-
$opt_H $opt_i $opt_j $opt_l $opt_N $opt_O $opt_o $opt_s $opt_t $opt_v
28-
$opt_X $opt_x /;
27+
$opt_H $opt_h $opt_i $opt_j $opt_l $opt_N $opt_O $opt_o $opt_s $opt_t
28+
$opt_v $opt_X $opt_x /;
2929

30-
our $VERSION = '1.2';
30+
our $VERSION = '1.3';
3131

3232
my ($offset1, $radix, $data, @arr, $lim);
3333
my ($lastline, $strfmt, $ml);
@@ -87,7 +87,7 @@ $lastline = '';
8787

8888
my $Program = basename($0);
8989

90-
getopts('A:aBbcdeFfHij:lN:Oost:vXx') or help();
90+
getopts('A:aBbcdeFfHhij:lN:Oost:vXx') or help();
9191
if (defined $opt_A) {
9292
if ($opt_A !~ m/\A[doxn]\z/) {
9393
warn "$Program: unexpected radix: '$opt_A'\n";
@@ -137,6 +137,9 @@ elsif ($opt_f) {
137137
elsif ($opt_H || $opt_X) {
138138
$fmt = \&hex4;
139139
}
140+
elsif ($opt_h || $opt_x) {
141+
$fmt = \&hex2;
142+
}
140143
elsif ($opt_i || $opt_s) {
141144
$fmt = \&decimal2;
142145
}
@@ -149,9 +152,6 @@ elsif ($opt_O) {
149152
elsif ($opt_B || $opt_o) {
150153
$fmt = \&octal2;
151154
}
152-
elsif ($opt_x) {
153-
$fmt = \&hex2;
154-
}
155155
else {
156156
$fmt = \&octal2;
157157
}
@@ -452,7 +452,7 @@ sub diffdata {
452452
}
453453

454454
sub help {
455-
print "usage: od [-aBbcdeFfHilOosXxv] [-A radix] [-j skip_bytes] ",
455+
print "usage: od [-aBbcdeFfHhilOosXxv] [-A radix] [-j skip_bytes] ",
456456
"[-N limit_bytes] [-t type] [file]...\n";
457457
exit EX_FAILURE;
458458
}
@@ -464,7 +464,7 @@ od - dump files in octal and other formats
464464
465465
=head1 SYNOPSIS
466466
467-
B<od> [ I<-aBbcdeFfHilOosXxv> ] [I<-j skip_bytes>] [I<-N limit_bytes>]
467+
B<od> [ I<-aBbcdeFfHhilOosXxv> ] [I<-j skip_bytes>] [I<-N limit_bytes>]
468468
[ I<-A radix> ] [ I<-t type> ] [ F<file>... ]
469469
470470
=head1 DESCRIPTION
@@ -523,6 +523,10 @@ Show input as floating point numbers in exponent form.
523523
524524
Four-byte hex display.
525525
526+
=item -h
527+
528+
Two-byte hex display.
529+
526530
=item -i
527531
528532
Show two-byte signed decimal integers.
@@ -584,7 +588,7 @@ Same as -H
584588
585589
=item -x
586590
587-
Use two-byte hexadecimal format.
591+
Same as -h
588592
589593
=item -v
590594

0 commit comments

Comments
 (0)