grep doesn't like ./ in pathnames

Have a question about our Software Developer Kit? Ask them here.
User avatar
Raziel
Posts: 997
Joined: Sat Jun 18, 2011 4:00 pm
Location: a dying planet

grep doesn't like ./ in pathnames

Post 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
People are dying.
Entire ecosystems are collapsing.
We are in the beginning of a mass extinction.
And all you can talk about is money and fairytales of eternal economic growth.
How dare you!
– Greta Thunberg
User avatar
Slayer
Beta Tester
Beta Tester
Posts: 851
Joined: Tue Dec 21, 2010 4:19 am
Location: New Zealand

Re: grep doesn't like ./ in pathnames

Post 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?
~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
Raziel
Posts: 997
Joined: Sat Jun 18, 2011 4:00 pm
Location: a dying planet

Re: grep doesn't like ./ in pathnames

Post 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
People are dying.
Entire ecosystems are collapsing.
We are in the beginning of a mass extinction.
And all you can talk about is money and fairytales of eternal economic growth.
How dare you!
– Greta Thunberg
User avatar
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 591
Joined: Sat Jun 18, 2011 2:40 am
Location: Portsmouth, UK
Contact:

Re: grep doesn't like ./ in pathnames

Post 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
User avatar
Slayer
Beta Tester
Beta Tester
Posts: 851
Joined: Tue Dec 21, 2010 4:19 am
Location: New Zealand

Re: grep doesn't like ./ in pathnames

Post 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
~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
Raziel
Posts: 997
Joined: Sat Jun 18, 2011 4:00 pm
Location: a dying planet

Re: grep doesn't like ./ in pathnames

Post 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
People are dying.
Entire ecosystems are collapsing.
We are in the beginning of a mass extinction.
And all you can talk about is money and fairytales of eternal economic growth.
How dare you!
– Greta Thunberg
User avatar
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 591
Joined: Sat Jun 18, 2011 2:40 am
Location: Portsmouth, UK
Contact:

Re: grep doesn't like ./ in pathnames

Post 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.
User avatar
Raziel
Posts: 997
Joined: Sat Jun 18, 2011 4:00 pm
Location: a dying planet

Re: grep doesn't like ./ in pathnames

Post 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
People are dying.
Entire ecosystems are collapsing.
We are in the beginning of a mass extinction.
And all you can talk about is money and fairytales of eternal economic growth.
How dare you!
– Greta Thunberg
User avatar
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 591
Joined: Sat Jun 18, 2011 2:40 am
Location: Portsmouth, UK
Contact:

Re: grep doesn't like ./ in pathnames

Post by broadblues »

my example is in a subdir so it has to be more than that.
User avatar
Raziel
Posts: 997
Joined: Sat Jun 18, 2011 4:00 pm
Location: a dying planet

Re: grep doesn't like ./ in pathnames

Post 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
People are dying.
Entire ecosystems are collapsing.
We are in the beginning of a mass extinction.
And all you can talk about is money and fairytales of eternal economic growth.
How dare you!
– Greta Thunberg
Post Reply