Author Topic: SGrep Issue with Wildcard (-wc) Switch  (Read 531 times)

mek

  • Junior Community Member
  • Posts: 6
  • Hero Points: 0
SGrep Issue with Wildcard (-wc) Switch
« on: June 06, 2024, 04:08:47 PM »
I'm using the version of sgrep distributed with VS 2023 and am encountering an issue when using the -wc switch to include multiple file name masks for searching against.  It would appear that when this option is enabled, the searching behaves in a manner that would be consistent with the -w (Match whole word) being enabled as well -- this is not what I desire :(

failing example:  sgrep -i -t -pc jojo -wc dbo.Test* dbo.RunTest*

Text that looks like "test_jojo" will not be matched, but if the command is changed to use individual sgrep invocations for each wildcard mask, the match will be found...

passing example:  sgrep -i -t -pc jojo dbo.Test*

Don't know when this behavior started as this is really the first time I've attempted to use the -wc switch...

Thanks for your help.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6937
  • Hero Points: 531
Re: SGrep Issue with Wildcard (-wc) Switch
« Reply #1 on: June 06, 2024, 07:30:47 PM »
If you're on Linux or macOS, you should quote the wildcards to make sure something weird doesn't happen.

sgrep -i -t -pc jojo -wc "dbo.Test*" "dbo.RunTest*"

mek

  • Junior Community Member
  • Posts: 6
  • Hero Points: 0
Re: SGrep Issue with Wildcard (-wc) Switch
« Reply #2 on: June 06, 2024, 08:11:17 PM »
Thanks Clark -- unfortunately quoting or not quoting the wildcard parameters does not make a difference in the results (this is on Windows btw). 

If I were a betting man, it really does look like there is a command line argument parsing issue with sgrep where it's accidentally turning on the "-w" switch when only a -wc switch is being supplied (again that's just my conclusion based on the observed behavior).

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6937
  • Hero Points: 531
Re: SGrep Issue with Wildcard (-wc) Switch
« Reply #3 on: June 06, 2024, 09:49:49 PM »
Interesting. It doesn't seem to work right unless you specify a path like this:

    sgrep -i -t -pc jojo . -wc dbo.Test* dbo.RunTest*

the above is equivalent to this:

    sgrep -i -t -pc jojo dbo.Test* dbo.RunTest*

The reason -wc was added is for users to avoid having to repeat long paths multiple times.

consider the following:

     sgrep -i -t -pc jojo c:\some\really\long\long\path\dbo.Test* c:\some\really\long\long\path\dbo.RunTest*

In this case use -wc like this:

     sgrep -i -t -pc jojo c:\some\really\long\long\path -wc dbo.Test* dbo.RunTest*

For now, always specify a path when using -wc.

We will look into this. It should still work without a path.

mek

  • Junior Community Member
  • Posts: 6
  • Hero Points: 0
Re: SGrep Issue with Wildcard (-wc) Switch
« Reply #4 on: June 06, 2024, 09:59:39 PM »
Thanks Clark

I concur that your "fix" of explicitly providing a "default" directory (i.e. .) when using -wc does indeed produce the results I would expect.