diff --git a/eg/substitute.py b/eg/substitute.py
index b19f457..8eb006e 100644
--- a/eg/substitute.py
+++ b/eg/substitute.py
@@ -1,6 +1,6 @@
import re
-
-
+import sys
+print('Imported Substitution', file=sys.stderr)
class Substitution:
"""
A substitution to be performed on a piece of text.
@@ -19,6 +19,7 @@ class Substitution:
self.pattern = pattern
self.repl = replacement
self.is_multiline = is_multiline
+ print(self,file=sys.stderr)
def apply_and_get_result(self, string):
"""
@@ -31,6 +32,12 @@ class Substitution:
compiled_pattern = re.compile(self.pattern)
result = re.sub(compiled_pattern, self.repl, string)
+ print(f'Did sub change anything? {result != string}',file=sys.stderr)
+ if result != string:
+ with open(f'orig.{hash(self.repl)}', 'w') as f:
+ f.write(string)
+ with open(f'subbed.{hash(self.repl)}', 'w') as f:
+ f.write(result)
return result
def __eq__(self, other):
If eg-config.squeeze = false causes following output:
Imported Substitution
while eg-config.squeeze = true causes:
Imported Substitution
<eg.substitute.Substitution object at 0x7f55c8029730>
<eg.substitute.Substitution object at 0x7f55c7bb63d0>
<eg.substitute.Substitution object at 0x7f55c7bb61c0>
Did sub change anything? True
Did sub change anything? True
Did sub change anything? False
[substitutions] section is completely ignored. Adding and removing entries from it doesn't cause above output to change. This is also confirmed by diffing orig.* and subbed.* files - only change is occasional newline removed (it looks like squeeze is done with Substitution).
Tested on latest git version with ./eg_exec.py ls >/dev/null.
Substitution from README doesn't work: ~/.egrc
Applying following patch:
If
eg-config.squeeze = false
causes following output:while
eg-config.squeeze = true
causes:[substitutions]
section is completely ignored. Adding and removing entries from it doesn't cause above output to change. This is also confirmed by diffingorig.*
andsubbed.*
files - only change is occasional newline removed (it looks likesqueeze
is done with Substitution).Tested on latest git version with
./eg_exec.py ls >/dev/null
.