tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Go packages with many dependencies



Am 15.08.2018 um 08:52 schrieb Jonathan Perkin:
> * On 2018-08-15 at 04:25 BST, Roland Illig wrote:
>> I prefer a uniform field separator. Isn't there some Make feature to access the n'th word of a variable? Like ${dep:S,:, ,g:[2]}? I think it's easier to read than the :C modifier.
> 
> I came to this same conclusion.  We discussed on IRC that in theory we
> should be able to use the :tsc and :[range] operators to do something
> like this:
> 
>   VAR:ts::[1]
> 
> to easily extract out a field, but it appears that doesn't work even
> though it should.

To replace spaces with colons, the :ts: modifier works nicely. But
that's the wrong direction for this case.

To replace colons with spaces, the :ts modifier cannot be used since
each GO_DEP only consists of a single word, so there is no separator
that could be inserted between words. I tried the following with bmake
from pkgsrc-current and with make(1) from NetBSD 7, and both work well.

VAR=            user:group:uid:gid

echo:
        @echo ${VAR:S,:, ,g:[1]}
        @echo ${VAR:S,:, ,g:[2]}
        @echo ${VAR:S,:, ,g:[3]}
        @echo ${VAR:S,:, ,g:[4]}

The :S modifier has been there since 1993, and the :[] modifier has been
added in Sep 2003, according to the make(1) man page. Both should be
widely usable by now.

Best,
Roland


Home | Main Index | Thread Index | Old Index