Deriving base port/package names

Roger Marquis marquis at
Fri Apr 8 16:53:55 UTC 2016

Matthew Seaman wrote:
> Put another way, if you're working with full pkgnames '%n-%v' it's always
> the last '-' character that separates the name from the version.

> $ pkgname='postgresql92-client-9.2.16'
> $ echo ${pkgname%-*}
> postgresql92-client
> $ echo ${pkgname##*-}
> 9.2.16

Those of us who prefer to avoid shell perlisms/bashisms (blessed by
POSIX' IBM/RH/Oracle-dominated board or not) appreciate your inclusion
of the equivalent sed regex.

> $ echo $pkgname | sed -e 's,-[^-]*$,,'
> postgresql92-client
> $ echo $pkgname | sed -e 's,^.*-,,'
> 9.2.16

> I think a proposal to rename large chunks of the ports tree to eliminate
> hyphens and digits would certainly not receive a warm welcome.

`pkg rquery -a %n | grep -- '-[0-9]' | wc -l` shows only 40 ports (of
25096).  Doesn't seem like a whole lot or a difficult refactor but
perhaps we're missing the use case of this particular group.  Anyone
know why these 40 ports are so named?


More information about the freebsd-ports mailing list