# flex version?



## estrabd (Sep 29, 2009)

I installed flex from 

ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-7.2-release/textproc/

Because I thought I had installed an unsupported version via ports, yet I still have this mismatch in the versions reported by pkg_info and flex itself.  Which one is right? I ask because I definitely don't want 2.5.4:


```
$pkg_info | grep flex
flex-2.5.35_1       Fast lexical analyzer generator
$flex -V
flex version 2.5.4
```

TIA!
:stud


----------



## DutchDaemon (Sep 29, 2009)

The port has 
	
	



```
PORTNAME=       flex
PORTVERSION=    2.5.35
PORTREVISION=   1
```

After a 'make':


```
/usr/ports/textproc/flex/work/flex-2.5.35]# ./flex -V
flex 2.5.35
```

No idea where your 2.54 comes from. The port and the package are at 2.5.35(_1).

Oh, wait  There's another flex:


```
# flex -V
flex version 2.5.4
```

It's part of the base system: /usr/bin/flex.

Try [cmd=]/usr/local/bin/flex -V[/cmd].


----------



## estrabd (Sep 29, 2009)

Thanks, DD. This solves the mystery.

NOW, aren't things in /usr/local/bin supposed to trump /usr/bin - or am I making this up.

I supposed I'll just adjust my path, but can you shed some light on dealing with this kind of situation?  I know when Perl was in base, there was a script that "updated" the Perl one saw. Is there a generic type of mechanism for this?

Cheers,
Brett

*UPDATE*

I saw that /usr/local indeed follows / and /usr. I symlinked /usr/local/bin/flex into my ~/bin, and I placed this directory in front of PATH. My question remains - how is one supposed to manage programs that are installed from ports that are also in base?  In my case, I needed an older version - but the same deal would apply regardless.  Thanks, again.


----------



## SirDice (Sep 29, 2009)

You should always supply the full path to the executable.


----------



## estrabd (Sep 29, 2009)

SirDice said:
			
		

> You should always supply the full path to the executable.



In what context? Are you saying that the PATH variable is evil?


----------



## SirDice (Sep 29, 2009)

estrabd said:
			
		

> In what context? Are you saying that the PATH variable is evil?



In scripts it's best to not rely on PATH and use the full paths to any executable. It's also the more 'safer' option, security-wise.


----------



## DutchDaemon (Sep 29, 2009)

I agree. I always use full paths to everything, even basic stuff like sed/grep/awk, chmod, chown, etc.


----------

