[BusyBox 0000624]: printf: please support POSIX quoted-argument-character syntax
bugs at busybox.net
bugs at busybox.net
Thu Jan 5 14:11:25 UTC 2006
The following issue has been SUBMITTED.
======================================================================
http://busybox.net/bugs/view.php?id=624
======================================================================
Reported By: Colin Watson
Assigned To: BusyBox
======================================================================
Project: BusyBox
Issue ID: 624
Category: New Features
Reproducibility: always
Severity: feature
Priority: normal
Status: assigned
======================================================================
Date Submitted: 01-05-2006 06:11 PST
Last Modified: 01-05-2006 06:11 PST
======================================================================
Summary: printf: please support POSIX
quoted-argument-character syntax
Description:
POSIX documents
(http://www.opengroup.org/onlinepubs/009695399/utilities/printf.html) the
following syntax for printf arguments:
The argument operands shall be treated as strings if the corresponding
conversion specifier is b, c, or s ; otherwise, it shall be evaluated
as a C constant, as described by the ISO C standard, with the
following extensions:
[...]
* If the leading character is a single-quote or double-quote, the
value shall be the numeric value in the underlying codeset of the
character following the single-quote or double-quote.
I found myself wanting this recently in order to convert non-devfs disk
device names into indices for display in a partitioning tool (e.g.
/dev/hde => "IDE2 master (hde)"). Lacking any other way to map from a-z to
0-25 in shell that I can think of, it was going to have to be a messy
sequence of sed commands until somebody pointed out this syntax to me.
With this patch, I can just do:
printf '%d\n' "'$character"
... to map from a-z to 0-25, which is much nicer. The small attached patch
implements this feature; I've checked it against the printf implementation
in GNU coreutils.
======================================================================
Issue History
Date Modified Username Field Change
======================================================================
01-05-06 06:11 Colin Watson New Issue
01-05-06 06:11 Colin Watson Status new => assigned
01-05-06 06:11 Colin Watson Assigned To => BusyBox
01-05-06 06:11 Colin Watson File Added: printf-quote-codepoint.patch
======================================================================
More information about the busybox-cvs
mailing list