Comment 1 for bug 26603

Revision history for this message
Andrew Snare (ajs-deactivatedaccount) wrote : Re: mawk substr() function is broken

It appears the situation is more complex than I thought; string indexing is apparently 1-based,
not 0-based as I previously thought.

The matter is summarised at: <http://lists.gnu.org/archive/html/bug-gnu-utils/2004-09/
msg00083.html>

Indeed the following works as expected:
% echo 1234 | mawk '{print substr($0,1,3)}'

It may be undesirable behaviour, but it's not a bug per se.

 - Andrew