Alan Barrett
2003-07-31 17:58:56 UTC
I propose adding a new :[] modifier to make(1) in NetBSD,
and possibly also adding some other modifiers.
":[]" will allow you to extract a single word from a space-separated list,
like this:
CC= /usr/bin/gcc -Wall
.if exists(${CC:[1]})
...
See http://mail-index.netbsd.org/tech-userlevel/2003/07/31/0000.html
for a post to NetBSD's tech-userlevel list where I discusssed the
problem and several proposed solutions. See other nearby messages
linked from http://mail-index.netbsd.org/tech-userlevel/2003/07/
for responses.
Briefly, the proposals are
:tW Set a flag that causes subsequent modifiers to treat the
value as a single entity instead of as a space-separated
list.
Why ":tW"? We already have :tu and :tl to convert to
upper or lower case, so starting with "t" is natural.
"tW" is supposed to suggest "convert to one big word".
:tw Undo the effect of :tW. "tw" is supposed to suggest
"convert to small words".
:C///W A "one big word" variant of the existing :C/// regular
expression substitution modifier. Unlike the usual
:C/// (which works separately on each space-separated
word), this would work on the entire string all at once,
so it would be able to match teh spaces between words.
:S///W A "one big word" variant of the existing :S/// simple
string substitution operator.
:[N] Select the Nth word, where N is a positive integer.
:[1] selects the first word.
:[-N] Select the Nth word from the end. :[-1] selects the
last word.
:[0] Select the entire string, but treat it as one big word.
(Equivalent to :tw.)
:[*] Select the entire string, treating it as a sequence of
space-separated words. (Undoes the effects of :[0];
equivalent to :tw.)
There seems to be support for adding :[] to NetBSD's make(1). :tW/:tw
and :C///W are not really necessary if you have :[0] and :[*], but they
might nevertheless be useful enough to add.
Would other BSDs be likely to pick up these features, or at least
not use the same modifier characters with incompatible meanings?
--apb (Alan Barrett)
---------------------------------------------------------------------
The BSD APIs Discussion Mailing List
To unsubscribe:
send "unsubscribe bsd-api-discuss" to majordomo-of7zbby7T3pWk0Htik3J/***@public.gmane.org
and possibly also adding some other modifiers.
":[]" will allow you to extract a single word from a space-separated list,
like this:
CC= /usr/bin/gcc -Wall
.if exists(${CC:[1]})
...
See http://mail-index.netbsd.org/tech-userlevel/2003/07/31/0000.html
for a post to NetBSD's tech-userlevel list where I discusssed the
problem and several proposed solutions. See other nearby messages
linked from http://mail-index.netbsd.org/tech-userlevel/2003/07/
for responses.
Briefly, the proposals are
:tW Set a flag that causes subsequent modifiers to treat the
value as a single entity instead of as a space-separated
list.
Why ":tW"? We already have :tu and :tl to convert to
upper or lower case, so starting with "t" is natural.
"tW" is supposed to suggest "convert to one big word".
:tw Undo the effect of :tW. "tw" is supposed to suggest
"convert to small words".
:C///W A "one big word" variant of the existing :C/// regular
expression substitution modifier. Unlike the usual
:C/// (which works separately on each space-separated
word), this would work on the entire string all at once,
so it would be able to match teh spaces between words.
:S///W A "one big word" variant of the existing :S/// simple
string substitution operator.
:[N] Select the Nth word, where N is a positive integer.
:[1] selects the first word.
:[-N] Select the Nth word from the end. :[-1] selects the
last word.
:[0] Select the entire string, but treat it as one big word.
(Equivalent to :tw.)
:[*] Select the entire string, treating it as a sequence of
space-separated words. (Undoes the effects of :[0];
equivalent to :tw.)
There seems to be support for adding :[] to NetBSD's make(1). :tW/:tw
and :C///W are not really necessary if you have :[0] and :[*], but they
might nevertheless be useful enough to add.
Would other BSDs be likely to pick up these features, or at least
not use the same modifier characters with incompatible meanings?
--apb (Alan Barrett)
---------------------------------------------------------------------
The BSD APIs Discussion Mailing List
To unsubscribe:
send "unsubscribe bsd-api-discuss" to majordomo-of7zbby7T3pWk0Htik3J/***@public.gmane.org