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 3: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
If slaughterhouses had glass walls, everyone would be a vegetarian. ~ Sir Paul McCartney
-
Did everything just taste purple for a second? ~ Philip J. Fry
-
Ain't got no cash, ain't got no style, ladies vomit when I smile. ~ Dr. John Zoidberg
User avatar
Raziel
 
Posts: 924
Joined: Sat Jun 18, 2011 5:00 pm
Location: a story that hasn't been written yet

Re: grep doesn't like ./ in pathnames

Postby Slayer » Sun Mar 04, 2012 4: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'~
1x AmigaOne X5000 2.0GHz 2gM RadeonR9280X AOS4.x
3x AmigaOne X1000 1.8GHz 2gM RadeonHD7970 AOS4.x
User avatar
Slayer
Beta Tester
Beta Tester
 
Posts: 851
Joined: Tue Dec 21, 2010 5:19 am
Location: New Zealand

Re: grep doesn't like ./ in pathnames

Postby Raziel » Sun Mar 04, 2012 11: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
If slaughterhouses had glass walls, everyone would be a vegetarian. ~ Sir Paul McCartney
-
Did everything just taste purple for a second? ~ Philip J. Fry
-
Ain't got no cash, ain't got no style, ladies vomit when I smile. ~ Dr. John Zoidberg
User avatar
Raziel
 
Posts: 924
Joined: Sat Jun 18, 2011 5:00 pm
Location: a story that hasn't been written yet

Re: grep doesn't like ./ in pathnames

Postby broadblues » Mon Mar 05, 2012 10: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
AmigaOS Core Developer
AmigaOS Core Developer
 
Posts: 591
Joined: Sat Jun 18, 2011 3:40 am
Location: Portsmouth, UK

Re: grep doesn't like ./ in pathnames

Postby Slayer » Tue Mar 06, 2012 3: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'~
1x AmigaOne X5000 2.0GHz 2gM RadeonR9280X AOS4.x
3x AmigaOne X1000 1.8GHz 2gM RadeonHD7970 AOS4.x
User avatar
Slayer
Beta Tester
Beta Tester
 
Posts: 851
Joined: Tue Dec 21, 2010 5:19 am
Location: New Zealand

Re: grep doesn't like ./ in pathnames

Postby Raziel » Tue Mar 06, 2012 9: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
If slaughterhouses had glass walls, everyone would be a vegetarian. ~ Sir Paul McCartney
-
Did everything just taste purple for a second? ~ Philip J. Fry
-
Ain't got no cash, ain't got no style, ladies vomit when I smile. ~ Dr. John Zoidberg
User avatar
Raziel
 
Posts: 924
Joined: Sat Jun 18, 2011 5:00 pm
Location: a story that hasn't been written yet

Re: grep doesn't like ./ in pathnames

Postby broadblues » Thu Mar 08, 2012 7: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
AmigaOS Core Developer
AmigaOS Core Developer
 
Posts: 591
Joined: Sat Jun 18, 2011 3:40 am
Location: Portsmouth, UK

Re: grep doesn't like ./ in pathnames

Postby Raziel » Sat Mar 10, 2012 3: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
If slaughterhouses had glass walls, everyone would be a vegetarian. ~ Sir Paul McCartney
-
Did everything just taste purple for a second? ~ Philip J. Fry
-
Ain't got no cash, ain't got no style, ladies vomit when I smile. ~ Dr. John Zoidberg
User avatar
Raziel
 
Posts: 924
Joined: Sat Jun 18, 2011 5:00 pm
Location: a story that hasn't been written yet

Re: grep doesn't like ./ in pathnames

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

my example is in a subdir so it has to be more than that.
User avatar
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
 
Posts: 591
Joined: Sat Jun 18, 2011 3:40 am
Location: Portsmouth, UK

Re: grep doesn't like ./ in pathnames

Postby Raziel » Tue Mar 13, 2012 2: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
If slaughterhouses had glass walls, everyone would be a vegetarian. ~ Sir Paul McCartney
-
Did everything just taste purple for a second? ~ Philip J. Fry
-
Ain't got no cash, ain't got no style, ladies vomit when I smile. ~ Dr. John Zoidberg
User avatar
Raziel
 
Posts: 924
Joined: Sat Jun 18, 2011 5:00 pm
Location: a story that hasn't been written yet

Next

Return to SDK Support

Who is online

Users browsing this forum: No registered users and 2 guests