Unexpected results with "-w" option
Brought to you by:
chilkoot
Bug reported to Fedora: the "-w" option gives unexpected results. I can reproduce this:
https://bugzilla.redhat.com/show_bug.cgi?id=519321
The test case copied from the above bug for reference:
Steps to Reproduce:
-------------------
#!/bin/bash
#creating data file
rm -f test1.txt;
SEQ1=$(seq 15000);
for i in $SEQ1
do
echo $i" : grande" >> test1.txt;
done
#running replace (with -w option -> 0 replaces)
SEQ2=$(seq 1);
for i in $SEQ2
do
rpl -w "rande" "grande" test1.txt;
done
#showing error (more than 1 replaces done)
grep gg test1.txt;
Actual results:
---------------
some replacements made(grande -> ggrande)
Expected results:
-----------------
no replacements made
Further related problem from https://bugzilla.redhat.com/show_bug.cgi?id=520064
Steps to Reproduce:
-------------------
#!/bin/bash
#creating data file
echo ".rande" > test2.txt
#running replace (with -w option)
rpl -w "rande" "grande" test2.txt
#word not changed (grep returns 0 lines)
grep grande test2.txt;
#grep catch correctly word boundaries
grep -w rande test2.txt;
Actual results:
---------------
change not made
'.rande' -> rpl -w "rande" "grande" -> '.rande'
Expected results:
-----------------
'rande' replaced by 'grande'
'.rande' -> rpl -w "rande" "grande" -> '.grande'