I'm writing a shell script which processes a text file line by line and compares each line to string arguments passed down from the command line. Actually it is trying to solve the old problem of, if you have false hits in Procmail, how to you figure out which pattern is causing the problem?
The core of the script is something like this:
The script basically works, and I found the offending Procmail pattern. But I observed that the script is not quite right as
the construct "$line" used several times is doing escape processing and will remove backslashes, etc. How do I get
"$line" to not do any escape processing but keep the incoming line of text totally intact and unaltered?
edit: hmmm... on further examination, it may be the read line command instead that is discarding backslashes...
How do I do a read without escape processing?
it looks like read in some shells has a -r option which probably does the job...
The core of the script is something like this:
Code:
sed -n -e ...pattern to pull RE's from Procmail | # pipe each Procmail RE into a while loop \
while read line
do
echo "$*" | if grep -q "$line"
then
echo "HIT: $line"
fi
done
The script basically works, and I found the offending Procmail pattern. But I observed that the script is not quite right as
the construct "$line" used several times is doing escape processing and will remove backslashes, etc. How do I get
"$line" to not do any escape processing but keep the incoming line of text totally intact and unaltered?
edit: hmmm... on further examination, it may be the read line command instead that is discarding backslashes...
How do I do a read without escape processing?
it looks like read in some shells has a -r option which probably does the job...