| Summary: | printf in awk fails to print zeros | ||
|---|---|---|---|
| Product: | Busybox | Reporter: | Yuri <yuri> |
| Component: | Other | Assignee: | unassigned |
| Status: | NEW --- | ||
| Severity: | normal | CC: | busybox-cvs, wolf+busybox |
| Priority: | P5 | ||
| Version: | 1.31.x | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | Linux | ||
| Host: | Target: | ||
| Build: | |||
|
Description
Yuri
2020-01-25 22:43:11 UTC
Printf seems easy enough to fix, but same issue is present also in sprintf, which would require more substantial changes to get right. Printf seems easy enough to fix, but same issue is present also in sprintf, which would require more substantial changes to get right. One thing worth noting is that current behaviour is strictly speaking POSIX compliant. (In reply to wolf+busybox from comment #3) Interesting. BSD awk also claims to be POSIX compliant: > The awk utility is compliant with the IEEE Std 1003.1-2008 (“POSIX.1”) > specification, except awk does not support {n,m} pattern matching. But I would favor practicality over technical standard compliance. (In reply to Yuri from comment #4) > Interesting. BSD awk also claims to be POSIX compliant: POSIX (on awk) just states that when printf should print \000, the behaviour is undefined. So both implementation's are compliant. > But I would favor practicality over technical standard compliance. Sure, why not. At least for printf it is very easy to resolve. sprintf would require larger changes. And it could be confusing for printf to allow \000 and sprintf to not allow it. I'm curious what conclusion will busybox people reach regarding this one. Does awk allow zeros in strings, and handle such strings properly? STL's std::string for example does allow zeros in the middle of strings, and handle them properly. On the contrary, shells don't allow zeros in strings. If awk generally doesn't handle zeros properly these two become separate issues. One is to print a zero to the output, the other one is to fix zero handling in strings. IMO, just fix them one by one. |