New options to handle decimal, octal and hexdecimal numbers

Hi @esr

There is a very old bug on Debian Bug Track System, asking for new options like -d, -o and -x. This bug is here[1] and I will copy and paste it below.

[1] https://bugs.debian.org/117764

Thanks in advance.

Cheers,

Eriberto

Hi,

When I'm looking up the ASCII character corresponding to a character code, I usually know what base I'm talking about, and I'd like to look it up directly.

'ascii 22' returns records for decimal 22, octal 22, and hexadecimal 22, and I have to look through those to find the one I knew I wanted in the first place. This is almost never the behaviour I want. 'ascii \22' and 'ascii \x22' work for octal and hexadecimal, but they're less than intuitive due partly to the necessity to escape backslashes for the shell, and there's no way I can see to get it to display only decimal output.

The obvious answer would be for 'ascii -d 22' to print only the ASCII record corresponding to decimal 22, and for -o and -x to behave similarly for octal and hexadecimal. Currently -d, -o, and -x ignore any subsequent arguments, but they could easily be extended in this way.

Thanks,

-- Colin Watson

Assignee Loading
Time tracking Loading