Tcl Source Code

View Ticket
Login
Ticket UUID: 3608714
Title: [string replace] refuses to replace empty substrings
Type: RFE Created on: 2013-03-21 14:11:51
Submitter: dgp Assigned to: dkf
Subsystem: 18. Commands M-Z Severity: Minor
Priority: 5 Medium Last modified: 2015-05-18 14:41:33
Status: Open Closed by: nobody
Resolution: None Closed on:
Version: current: 8.6.0
Description:
Can't believe I missed this.  Should have been part
of the Do Nothing Gracefully cleanup.

You cannot use [string replace] to insert a substring
without at the same time taking at least on character
out.

% string replace abcde 1 0 h
abcde

Instead of the result any sane programmer would
expect:

ahbcde

In particular, the useful case of prepending is not
supported.

Recategorize to a Feature Request if you must.  (This
misfeature is documented, FFS).  But it's so boneheaded
it looks like a bug to me.
User Comments:
dgp added on 2013-04-10 21:18:06:
See branch bug-3608714.

Surprising thing is that the test suite does not care.

dgp added on 2015-02-18 20:45:35:
See also:

https://sourceforge.net/p/tcl/mailman/message/20466029/

dkf added on 2015-02-18 21:49:17:

Bug-by-design? Meh. While I think this is something that will need flagging up as a change when it gets done, it can probably go on the 8.6 track as who in their right mind would be relying on the current behaviour?


dgp added on 2015-02-18 21:58:00:
I no longer recall, but whatever it was, it was enough
to suspend the feature change at the time.

I'd start looking with tcllib.

dgp added on 2015-05-18 14:41:33:
bug-3608714 branch updated.