grep doesn't like ./ in pathnames

Have a question about our Software Developer Kit? Ask them here.

grep doesn't like ./ in pathnames

Postby Raziel » Sun Mar 04, 2012 2:25 am

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
Image
If slaughterhouses had glass walls, everyone would be a vegetarian ~ Paul McCartney
--
AmigaOS4 does not have bugs -- it just develops random features ;-)
User avatar
Raziel
 
Posts: 278
Joined: Sat Jun 18, 2011 4:00 pm
Location: In a Castle in the Bavarian Mountains

Re: grep doesn't like ./ in pathnames

Postby Slayer » Sun Mar 04, 2012 3:09 am

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?
~Yes I am a Kiwi, No, I did not appear as an extra in 'Lord of the Rings'~
2x X1000 1.8GHz 2gM RadeonHD7970 AOS4.x
3x Sam Flex (667MHz, 733MHz & 800MHz models) 1gM Radeon9250 AOS4.x
Sam 667MHz .5gM RadeonM9 AOS4.x
A4000D 604e 233Mhz .125gM Voodoo3 AOS4.x
User avatar
Slayer
Beta Tester
Beta Tester
 
Posts: 702
Joined: Tue Dec 21, 2010 4:19 am
Location: New Zealand

Re: grep doesn't like ./ in pathnames

Postby Raziel » Sun Mar 04, 2012 10:28 am

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
Image
If slaughterhouses had glass walls, everyone would be a vegetarian ~ Paul McCartney
--
AmigaOS4 does not have bugs -- it just develops random features ;-)
User avatar
Raziel
 
Posts: 278
Joined: Sat Jun 18, 2011 4:00 pm
Location: In a Castle in the Bavarian Mountains

Re: grep doesn't like ./ in pathnames

Postby broadblues » Mon Mar 05, 2012 9:33 pm

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
User avatar
broadblues
Beta Tester
Beta Tester
 
Posts: 65
Joined: Sat Jun 18, 2011 2:40 am
Location: Portsmouth, UK

Re: grep doesn't like ./ in pathnames

Postby Slayer » Tue Mar 06, 2012 2:25 am

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
~Yes I am a Kiwi, No, I did not appear as an extra in 'Lord of the Rings'~
2x X1000 1.8GHz 2gM RadeonHD7970 AOS4.x
3x Sam Flex (667MHz, 733MHz & 800MHz models) 1gM Radeon9250 AOS4.x
Sam 667MHz .5gM RadeonM9 AOS4.x
A4000D 604e 233Mhz .125gM Voodoo3 AOS4.x
User avatar
Slayer
Beta Tester
Beta Tester
 
Posts: 702
Joined: Tue Dec 21, 2010 4:19 am
Location: New Zealand

Re: grep doesn't like ./ in pathnames

Postby Raziel » Tue Mar 06, 2012 8:37 pm

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
Image
If slaughterhouses had glass walls, everyone would be a vegetarian ~ Paul McCartney
--
AmigaOS4 does not have bugs -- it just develops random features ;-)
User avatar
Raziel
 
Posts: 278
Joined: Sat Jun 18, 2011 4:00 pm
Location: In a Castle in the Bavarian Mountains

Re: grep doesn't like ./ in pathnames

Postby broadblues » Thu Mar 08, 2012 6:56 pm

@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.
User avatar
broadblues
Beta Tester
Beta Tester
 
Posts: 65
Joined: Sat Jun 18, 2011 2:40 am
Location: Portsmouth, UK

Re: grep doesn't like ./ in pathnames

Postby Raziel » Sat Mar 10, 2012 2:14 pm

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
Image
If slaughterhouses had glass walls, everyone would be a vegetarian ~ Paul McCartney
--
AmigaOS4 does not have bugs -- it just develops random features ;-)
User avatar
Raziel
 
Posts: 278
Joined: Sat Jun 18, 2011 4:00 pm
Location: In a Castle in the Bavarian Mountains

Re: grep doesn't like ./ in pathnames

Postby broadblues » Sun Mar 11, 2012 1:35 am

my example is in a subdir so it has to be more than that.
User avatar
broadblues
Beta Tester
Beta Tester
 
Posts: 65
Joined: Sat Jun 18, 2011 2:40 am
Location: Portsmouth, UK

Re: grep doesn't like ./ in pathnames

Postby Raziel » Tue Mar 13, 2012 1:19 am

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
Image
If slaughterhouses had glass walls, everyone would be a vegetarian ~ Paul McCartney
--
AmigaOS4 does not have bugs -- it just develops random features ;-)
User avatar
Raziel
 
Posts: 278
Joined: Sat Jun 18, 2011 4:00 pm
Location: In a Castle in the Bavarian Mountains

Next

Return to SDK Support

Who is online

Users browsing this forum: No registered users and 1 guest