# case insensitive pkg_info



## Seeker (Jan 8, 2014)

```
pkg_info -EX geo
```
I want it to output


> GeoIP-1.4.8_3


----------



## DutchDaemon (Jan 8, 2014)

Try -ix.


----------



## wblock@ (Jan 8, 2014)

That works on pkg(8).  I thought it was -Ix, but neither of those is for case-insensitive on pkg_info(1).


----------



## DutchDaemon (Jan 8, 2014)

I seem to recall an -IX flag, even.


----------



## ShelLuser (Jan 8, 2014)

It's actually a combination of several options, and of course the answer can be found in the pkg_info(1) manualpage.


```
smtp2:/home/peter/temp $ pkg_info -EIx geo
pecl-geoip-1.0.8
webalizer-geoip-2.23.8
```
The -x (or -X, it's merely an advanced regexp) takes care of the match making of the package name. By using the -E option it makes -I obsolete, but the reason I used it is force of habbit. -I takes care of only printing a one line package description instead of a full informative header, and it's an option (-Ix) I regularly use.

So finally the -E; it takes care of only showing matching package names, which is why you don't get any descriptions. As said, I could have used -Ex as well, this approach is simply force of habit on my end.


----------



## Seeker (Jan 9, 2014)

None of you gave me a proper reply, thus you instead answered me what I already knew and haven't asked. Let's attempt again. If you have any ports, then libiconv is something you all surely have.

Before even attempting to post exec_ute_ this:

```
pkg_info -EX iconv
```
If you get output:

```
libiconv-1.14_1
```
Then Voila! Now you are eligible to proceed in helping.

We want _the_ same output, but in a case insensitive way. This command must emit the same output, thus we'll have to have something modified: `pkg_info -EX IcOnV`. Note that IcOnV is an extended regex, so how do we pass/glue a modifier to it, which does case insensitive matching? re_format(7) describes how it works, but not how to pass _a_ modifier.


----------



## DutchDaemon (Jan 9, 2014)

Next time, try asking the question properly then. If no one answers it correctly, the question was wrong. Looking at the original question again, the intent wasn't clear at all.

Try `pkg_info -EX [gG]eo` and or `pkg_info -EX [iI][cC][oO][nN][vV]`.

They're regular expressions, meaning: you have to write them as such.


----------



## Seeker (Jan 9, 2014)

> If case-independent matching is specified, the effect is much as if all
> case distinctions had vanished from the alphabet.	When an alphabetic
> that exists in multiple cases appears as an ordinary character outside a
> bracket expression, it is effectively transformed into a bracket expres-
> ...


The point is, I want to pass one flag, instead _of_ typing it the way you did, so RE a regex would do a translat_ion_ for me.


----------



## DutchDaemon (Jan 9, 2014)

That flag does not exist, and it will not be created (because pkg_* tools are on their way out). It has been implemented in PKGNG:


```
$ pkg info -ix iCoNv                                                                                                                               
libiconv-1.14_1
```


----------



## Seeker (Jan 10, 2014)

DutchDaemon said:
			
		

> That flag does not exist, and it will not be created (because pkg_* tools are on their way out). It has been implemented in PKGNG:
> 
> 
> ```
> ...



You should look at it, the other way around. I mentioned *RE_FORMAT(7)*.
Just imagine it as a lib used by grep, sed, pkg_* and possibly other bins.
*RE Lib's* rules *are the one* which should be same to all bins using it!
Let's take *grep* as example. It should be possible to enable case insensitive matching, *even -i flag hasn't been passed*, simply by issuing modifier *as part of RE*.
Then same RE behaves same for ALL bins (grep, sed, ... ). And yes, pkg_*
sed has an "I" modifier *as part of RE* which does exactly what I want.

Anyway, in a meantime, I've found it on my own:

```
pkg_glob :'(?i)geo'
```
It produces EXACTLY output which I need:

```
GeoIP-1.4.8_3
```

I'll shift scripts to PKGNG when they become part of base


----------



## wblock@ (Jan 10, 2014)

pkg_glob is part of ports-mgmt/portupgrade.  It's not from the base system.


----------



## kpa (Jan 10, 2014)

PKGNG will not be imported to base, it is meant to stay in ports for easy updates.


----------



## Seeker (Jan 11, 2014)

wblock@ said:
			
		

> pkg_glob is part of ports-mgmt/portupgrade.  It's not from the base system.


Yes I know, but it is so essential as iconv or perl is. :beergrin


----------

