Problems using regexp with cygwin diff on Windows 2000

J

Joerg Moeller

Hello!

I was thinking quite some time if this is the correct group to post to
because actually the problem isn't so much related to the regex but to
os issues. I was wondering if I should post it to unix, msdos,
windows, gnu.... related group but finally decided to try it here
because I hope that here are some experts around with experience in
unix, windows, msdos and gnu. If you could point me to the correct
group I would appreciate it.

Actually the whole problem is that I'm on an Windows 2000 box and need
to use the cygwin diff tool together with a regular expression to omit
some lines. Unfortunately the lines I want to omit contains multiple
occurances of >'<. Even more unfortunately the regular expression for
diff shall be surrounded by >'<. Even if escape the >'< in the regular
expression the diff tool thinks it's the end of the regular expression
and is omplaining about the rest.

Example:

diff -I '^\s*VERSION' aCMNdiskDriveController.contrib1
aCMNdiskDriveController.base

works fine but the regular expression is incomplete. A more complete
expression would be

C:\cygwin\bin>diff -I '^\s*VERSION [\w\d\\_\.\']*'
aCMNdiskDriveController.contrib1 aCMNdiskDriveController.base

What give the following error:
diff: missing operand after `\s*VERSION [\w\d\_\.']*
aCMNdiskDriveController.contrib1 aCMNdiskDriveController.base'
diff: Try `diff --help' for more information.

Anybody an idea what's wrong or how to work around this problem?

Regards
Joerg
 
B

Bob Walton

Joerg Moeller wrote:

....
Example:

diff -I '^\s*VERSION' aCMNdiskDriveController.contrib1
aCMNdiskDriveController.base

works fine but the regular expression is incomplete. A more complete
expression would be

C:\cygwin\bin>diff -I '^\s*VERSION [\w\d\\_\.\']*'
aCMNdiskDriveController.contrib1 aCMNdiskDriveController.base

What give the following error:
diff: missing operand after `\s*VERSION [\w\d\_\.']*
aCMNdiskDriveController.contrib1 aCMNdiskDriveController.base'
diff: Try `diff --help' for more information.

Anybody an idea what's wrong or how to work around this problem? ....
Joerg


What shell are you running? bash? If so, did you read in the man page
where it says:


"A single quote may not occur between single quotes, even when pre-
ceded by a backslash."

You will thus need to use an appropriate quoting mechanism for putting
the apostrophe into your regexp. Maybe something like [untested]:

diff -I '^\s*VERSION [\w\d\\_\.\'"'"']*' file1 file2

And yes, you're way off-topic for this newsgroup :)
 
G

Gerhard Heift

Joerg said:
Example:

diff -I '^\s*VERSION' aCMNdiskDriveController.contrib1
aCMNdiskDriveController.base

works fine but the regular expression is incomplete. A more complete
expression would be

C:\cygwin\bin>diff -I '^\s*VERSION [\w\d\\_\.\']*'
aCMNdiskDriveController.contrib1 aCMNdiskDriveController.base

What give the following error:
diff: missing operand after `\s*VERSION [\w\d\_\.']*
aCMNdiskDriveController.contrib1 aCMNdiskDriveController.base'
diff: Try `diff --help' for more information.

Anybody an idea what's wrong or how to work around this problem?

Untestet:

C:\cygwin\bin>diff -I "^\s*VERSION [\w\d\\_\.\']*"

With doublequotes ("), not singel-ones (').

Pherhaps it works...

Gerhard
 
J

Joerg Moeller

Bob Walton said:
Joerg Moeller wrote:

...
Example:

diff -I '^\s*VERSION' aCMNdiskDriveController.contrib1
aCMNdiskDriveController.base

works fine but the regular expression is incomplete. A more complete
expression would be

C:\cygwin\bin>diff -I '^\s*VERSION [\w\d\\_\.\']*'
aCMNdiskDriveController.contrib1 aCMNdiskDriveController.base

What give the following error:
diff: missing operand after `\s*VERSION [\w\d\_\.']*
aCMNdiskDriveController.contrib1 aCMNdiskDriveController.base'
diff: Try `diff --help' for more information.

Anybody an idea what's wrong or how to work around this problem? ...
Joerg


What shell are you running? bash? If so, did you read in the man page
where it says:

Not using bash, just simple plain MS-DOS Shell.
"A single quote may not occur between single quotes, even when pre-
ceded by a backslash."

You will thus need to use an appropriate quoting mechanism for putting
the apostrophe into your regexp. Maybe something like [untested]:

diff -I '^\s*VERSION [\w\d\\_\.\'"'"']*' file1 file2

This seems to make the trick ;-) unfortunately if I'm expanding the
repexp it doesn't match any longer. The line to be matched is
something like:

VERSION 'kiel_int_v3.6.x\dev_v3.6.8_ellerbrock_01\2' LIBRARY
'z:\CMN\objectime.otlib'

And

diff -I '^\s*VERSION [\w\d\\_\.\'"'"']*' file1 file2

works and ignores this line but

diff -I '^\s*VERSION [\w\d\\_\.\'"'"']*?\s* LIBRARY' file1 file2

doesn't work and display the line as difference.
And yes, you're way off-topic for this newsgroup :)

I'm aware of it. But any other idea where to post this? I'm really
beeing desperate and was quite unsure if I should post it here ;-)

Many thanks for your help.

regards
Joerg
 
J

Joerg Moeller

Gerhard Heift said:
Joerg said:
Example:

diff -I '^\s*VERSION' aCMNdiskDriveController.contrib1
aCMNdiskDriveController.base

works fine but the regular expression is incomplete. A more complete
expression would be

C:\cygwin\bin>diff -I '^\s*VERSION [\w\d\\_\.\']*'
aCMNdiskDriveController.contrib1 aCMNdiskDriveController.base

What give the following error:
diff: missing operand after `\s*VERSION [\w\d\_\.']*
aCMNdiskDriveController.contrib1 aCMNdiskDriveController.base'
diff: Try `diff --help' for more information.

Anybody an idea what's wrong or how to work around this problem?

Untestet:

C:\cygwin\bin>diff -I "^\s*VERSION [\w\d\\_\.\']*"

With doublequotes ("), not singel-ones (').

Pherhaps it works...

Gerhard

Gerhard,

already tried it. Doesn't work ;-) Thank you for your help anyway.

regards
Joerg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top