Hi all
I've developped a script for checking that quotes are balanced in other scripts. It looks like
So far so good but, if ever a script screamed for a loop it's this one. I get as far as
and then it all goes wrong.
Any ideas/pointers would be more than welcome.
On the internet no one knows you're a dog
Columb Healy
I've developped a script for checking that quotes are balanced in other scripts. It looks like
Code:
#!/bin/ksh
[[ $# -ne 1 ]] && { echo invalid param count; exit 1; }
[[ -r $1 ]] || { echo Unable to read $1; exit 1; }
awk -v CH=\' '{
occ=0;
while (y=index($0,CH))
{
occ++;
y++;
$0=substr($0,y);
}
if (occ%2)
print "line " NR ": " occ " occurrences of " CH
}' $1
awk -v CH=\" '{
occ=0;
while (y=index($0,CH))
{
occ++;
y++;
$0=substr($0,y);
}
if (occ%2)
print "line " NR ": " occ " occurrences of " CH
}' $1
awk -v CH=\` '{
occ=0;
while (y=index($0,CH))
{
occ++;
y++;
$0=substr($0,y);
}
if (occ%2)
print "line " NR ": " occ " occurrences of " CH
}' $1
Code:
#!/bin/ksh
[[ $# -ne 1 ]] && { echo invalid param count; exit 1; }
[[ -r $1 ]] || { echo Unable to read $1; exit 1; }
for quote in \' \" \`
do
awk -v CH=
Any ideas/pointers would be more than welcome.
On the internet no one knows you're a dog
Columb Healy