Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

od: add -h alias for -x #937

Merged
merged 1 commit into from
Jan 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions bin/od
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ use constant LINESZ => 16;
use constant PRINTMAX => 126;

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

our $VERSION = '1.2';
our $VERSION = '1.3';

my ($offset1, $radix, $data, @arr, $lim);
my ($lastline, $strfmt, $ml);
Expand Down Expand Up @@ -87,7 +87,7 @@ $lastline = '';

my $Program = basename($0);

getopts('A:aBbcdeFfHij:lN:Oost:vXx') or help();
getopts('A:aBbcdeFfHhij:lN:Oost:vXx') or help();
if (defined $opt_A) {
if ($opt_A !~ m/\A[doxn]\z/) {
warn "$Program: unexpected radix: '$opt_A'\n";
Expand Down Expand Up @@ -137,6 +137,9 @@ elsif ($opt_f) {
elsif ($opt_H || $opt_X) {
$fmt = \&hex4;
}
elsif ($opt_h || $opt_x) {
$fmt = \&hex2;
}
elsif ($opt_i || $opt_s) {
$fmt = \&decimal2;
}
Expand All @@ -149,9 +152,6 @@ elsif ($opt_O) {
elsif ($opt_B || $opt_o) {
$fmt = \&octal2;
}
elsif ($opt_x) {
$fmt = \&hex2;
}
else {
$fmt = \&octal2;
}
Expand Down Expand Up @@ -452,7 +452,7 @@ sub diffdata {
}

sub help {
print "usage: od [-aBbcdeFfHilOosXxv] [-A radix] [-j skip_bytes] ",
print "usage: od [-aBbcdeFfHhilOosXxv] [-A radix] [-j skip_bytes] ",
"[-N limit_bytes] [-t type] [file]...\n";
exit EX_FAILURE;
}
Expand All @@ -464,7 +464,7 @@ od - dump files in octal and other formats

=head1 SYNOPSIS

B<od> [ I<-aBbcdeFfHilOosXxv> ] [I<-j skip_bytes>] [I<-N limit_bytes>]
B<od> [ I<-aBbcdeFfHhilOosXxv> ] [I<-j skip_bytes>] [I<-N limit_bytes>]
[ I<-A radix> ] [ I<-t type> ] [ F<file>... ]

=head1 DESCRIPTION
Expand Down Expand Up @@ -523,6 +523,10 @@ Show input as floating point numbers in exponent form.

Four-byte hex display.

=item -h

Two-byte hex display.

=item -i

Show two-byte signed decimal integers.
Expand Down Expand Up @@ -584,7 +588,7 @@ Same as -H

=item -x

Use two-byte hexadecimal format.
Same as -h

=item -v

Expand Down
Loading