Skip to content

Commit

Permalink
od: support -B alias for -o
Browse files Browse the repository at this point in the history
* Free/Net/Open BSDs document that "od -B" behaves the same as -o
* GNU version appears to support this as well, but I couldn't find reference to this in its manual
  • Loading branch information
mknos authored Jun 27, 2024
1 parent 861c950 commit abe8013
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions bin/od
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ use constant EX_FAILURE => 1;
use constant LINESZ => 16;
use constant PRINTMAX => 126;

use vars qw/ $opt_A $opt_a $opt_b $opt_c $opt_d $opt_f $opt_i $opt_j $opt_l
$opt_N $opt_o $opt_s $opt_v $opt_x /;
use vars qw/ $opt_A $opt_a $opt_B $opt_b $opt_c $opt_d $opt_f $opt_i $opt_j
$opt_l $opt_N $opt_o $opt_s $opt_v $opt_x /;

our $VERSION = '1.0';

Expand Down Expand Up @@ -85,7 +85,7 @@ $lastline = '';

my $Program = basename($0);

getopts('A:abcdfij:lN:osvx') or help();
getopts('A:aBbcdfij:lN:osvx') or help();
if (defined $opt_A) {
if ($opt_A !~ m/\A[doxn]\z/) {
warn "$Program: unexpected radix: '$opt_A'\n";
Expand Down Expand Up @@ -135,7 +135,7 @@ elsif ($opt_i || $opt_s) {
elsif ($opt_l) {
$fmt = \&long;
}
elsif ($opt_o) {
elsif ($opt_B || $opt_o) {
$fmt = \&octal2;
}
elsif ($opt_x) {
Expand Down Expand Up @@ -348,7 +348,7 @@ sub diffdata {
}

sub help {
print "usage: od [-abcdfilosxv] [-A radix] [-j skip_bytes] [-N limit_bytes] [file]...\n";
print "usage: od [-aBbcdfilosxv] [-A radix] [-j skip_bytes] [-N limit_bytes] [file]...\n";
exit EX_FAILURE;
}
__END__
Expand All @@ -359,7 +359,7 @@ od - dump files in octal and other formats
=head1 SYNOPSIS
B<od> [ I<-abcdfilosxv> ] [I<-j skip_n_bytes>] [I<-N read_n_bytes>] [ I<-A radix> ] [ F<file>... ]
B<od> [ I<-aBbcdfilosxv> ] [I<-j skip_n_bytes>] [I<-N read_n_bytes>] [ I<-A radix> ] [ F<file>... ]
=head1 DESCRIPTION
Expand All @@ -385,6 +385,10 @@ Select offset prefix format: 'd' for decimal, 'o' for octal, 'x' for hexadecimal
Dump characters in 7-bit ASCII format, ignoring the highest bit of each byte.
The names of ASCII control characters are displayed.
=item -B
Same as -o
=item -b
Single-byte octal display.
Expand Down

0 comments on commit abe8013

Please sign in to comment.