Page 1 of 3

grep doesn't like ./ in pathnames

Posted: Sun Mar 04, 2012 2:25 am
by Raziel
This
grep VERSION "./base/internal_version.h" | cut -d\" -f2
won't work and will quit with an error because grep cannot handle ./ in pathnames.

Removeing the ./ works just fine

It would be nice if this can be fixed/added in a next grep version

Sorry if this is the wrong forum, i wasn't sure if it is part of adtools

Re: grep doesn't like ./ in pathnames

Posted: Sun Mar 04, 2012 3:09 am
by Slayer
I didn't actually think ./ ever worked?

/root dir/ did though?

for example I don't think I could never type

sh ./configure

had to cd to the directory then type sh configure

that aside since it's probably not even applicable anymore, it's a been a few years since I've configured anything ;)

Does dropping into sh first change anything? and what exactly (without me reading the docs) does that grep line set out to do?

It looks like it checks for something then does something if or when it encounters it?

Re: grep doesn't like ./ in pathnames

Posted: Sun Mar 04, 2012 10:28 am
by Raziel
Slayer wrote:I didn't actually think ./ ever worked?

/root dir/ did though?

for example I don't think I could never type

sh ./configure

had to cd to the directory then type sh configure myself too

that aside since it's probably not even applicable anymore, it's a been a few years since I've configured anything ;)

Does dropping into sh first change anything? and what exactly (without me reading the docs) does that grep line set out to do?

It looks like it checks for something then does something if or when it encounters it?
I am in sh, but the line is taken out of a more complex shell command line.
It was this exact command that broke the whole process.

I do need to enter the dir before using sh to use ./configure

The command itself looks for base/internal_version.h, greps the information it finds for VERSION inside this file cuts out the needed part and returns it, i.e. "1.3.19" whereas the line in internal_version.h looks something like this
#define VERSION "1.3.19" REVISION

Re: grep doesn't like ./ in pathnames

Posted: Mon Mar 05, 2012 9:33 pm
by broadblues
10.RAM Disk:T> grep "hid" ./usb.log
I: [18:56:34] hid.usbfd | HID driver | USB Interface bound
I: [18:56:34] hid.usbfd | HID driver | USB Interface bound
I: [18:56:34] hid.usbfd | HID driver | USB Interface bound

10.RAM Disk:T> grep --version
GNU grep 2.5.4


no issue there with ./ so i wonder are you using the right grep?

to make it closer to your example


/RAM Disk>grep "hid" ./T/usb.log | cut -d\| -f2
HID driver
HID driver
HID driver

Re: grep doesn't like ./ in pathnames

Posted: Tue Mar 06, 2012 2:25 am
by Slayer
I was trying to do a test case too with this version but every time I introduced the | string it returned the wrong thing, I just put it down to being tired and left it for another day.

I then thought perhaps he is in a different level of directory than the same directory as ./whatever because doesn't ./ mean one directory down from root? eg ../ is two levels down or up? lol

Re: grep doesn't like ./ in pathnames

Posted: Tue Mar 06, 2012 8:37 pm
by Raziel
The test case i provided was ripped from the original line which is part of a bash batch script

It originally something like this (NOT working as i cant access the right site atm)

VERSION = (shell grep VERSION "((rootdir))/base/internal_version.h ! cut /d" -f2)

the double (( are normally waved (

I hate the keyboard on this public pc

I will post the right line when i have the chance and also the workaround

Thanks for trying though

Re: grep doesn't like ./ in pathnames

Posted: Thu Mar 08, 2012 6:56 pm
by broadblues
@Slayer
I was trying to do a test case too with this version but every time I introduced the | string it returned the wrong thing, I just put it down to being tired and left it for another day.
The Pipe "|" only works in abc-shell in this case.

Re: grep doesn't like ./ in pathnames

Posted: Sat Mar 10, 2012 2:14 pm
by Raziel
broadblues wrote:@Slayer
I was trying to do a test case too with this version but every time I introduced the | string it returned the wrong thing, I just put it down to being tired and left it for another day.
The Pipe "|" only works in abc-shell in this case.
Not sure, but i think i use abc-shell, so pipe should work.

I think it comes down to being a path issue when the file in question lies in a sudbir, like
./subdir/file-in-question

then, i think, it refuses to work properly

Re: grep doesn't like ./ in pathnames

Posted: Sun Mar 11, 2012 1:35 am
by broadblues
my example is in a subdir so it has to be more than that.

Re: grep doesn't like ./ in pathnames

Posted: Tue Mar 13, 2012 1:19 am
by Raziel
There you go
VERSION = $(shell grep SCUMMVM_VERSION "${srcdir}/base/internal_version.h" | cut -d\" -f2)
doesn´t work.

You can try the line
grep SCUMMVM_VERSION "./base/internal_version.h"
in abc-shell.

The {srcdir} part will always be translated into "." at least for me, which won´t work then.

You can find internal_version.h here