2020-11-20 03:54:37 +00:00
|
|
|
# $NetBSD: modts.mk,v 1.8 2020/11/03 18:42:33 rillig Exp $
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2020-11-20 03:54:37 +00:00
|
|
|
LIST= one two three four five six
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2020-11-07 19:39:21 +00:00
|
|
|
FU_mod-ts= a / b / cool
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2020-11-07 19:39:21 +00:00
|
|
|
AAA= a a a
|
|
|
|
B.aaa= Baaa
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2020-09-05 16:11:04 +00:00
|
|
|
all: mod-ts mod-ts-space
|
2012-06-08 21:57:36 +00:00
|
|
|
|
|
|
|
# Use print or printf iff they are builtin.
|
2020-11-07 19:39:21 +00:00
|
|
|
# XXX note that this causes problems, when make decides
|
2012-06-08 21:57:36 +00:00
|
|
|
# there is no need to use a shell, so avoid where possible.
|
2015-12-07 22:51:25 +00:00
|
|
|
.if ${(type print) 2> /dev/null || echo:L:sh:Mbuiltin} != ""
|
2020-11-07 19:39:21 +00:00
|
|
|
PRINT= print -r --
|
2015-12-07 22:51:25 +00:00
|
|
|
.elif ${(type printf) 2> /dev/null || echo:L:sh:Mbuiltin} != ""
|
2020-11-07 19:39:21 +00:00
|
|
|
PRINT= printf '%s\n'
|
2012-06-08 21:57:36 +00:00
|
|
|
.else
|
2020-11-07 19:39:21 +00:00
|
|
|
PRINT= echo
|
2012-06-08 21:57:36 +00:00
|
|
|
.endif
|
|
|
|
|
|
|
|
mod-ts:
|
|
|
|
@${PRINT} 'LIST:tx="${LIST:tx}"'
|
2016-03-11 00:37:02 +00:00
|
|
|
@${PRINT} 'LIST:ts/x:tu="${LIST:ts\X:tu}"'
|
2012-06-08 21:57:36 +00:00
|
|
|
@${PRINT} 'FU_$@="${FU_${@:ts}:ts}"'
|
|
|
|
@${PRINT} 'FU_$@:ts:T="${FU_${@:ts}:ts:T}" == cool?'
|
|
|
|
@${PRINT} 'B.$${AAA:ts}="${B.${AAA:ts}}" == Baaa?'
|
2020-09-05 16:11:04 +00:00
|
|
|
|
|
|
|
mod-ts-space:
|
|
|
|
# After the :ts modifier, the whole string is interpreted as a single
|
|
|
|
# word since all spaces have been replaced with x.
|
|
|
|
@${PRINT} ':ts :S => '${aa bb aa bb aa bb:L:tsx:S,b,B,:Q}
|
|
|
|
|
|
|
|
# The :ts modifier also applies to word separators that are added
|
|
|
|
# afterwards.
|
|
|
|
@${PRINT} ':ts :S space => '${a ababa c:L:tsx:S,b, ,g:Q}
|
|
|
|
@${PRINT} ':ts :S space :M => '${a ababa c:L:tsx:S,b, ,g:M*:Q}
|
|
|
|
|
|
|
|
# Not all modifiers behave this way though. Some of them always use
|
|
|
|
# a space as word separator instead of the :ts separator.
|
|
|
|
# This seems like an oversight during implementation.
|
|
|
|
@${PRINT} ':ts :S => '${a ababa c:L:tsx:S,b, ,g:Q}
|
|
|
|
@${PRINT} ':ts :S :@ => '${a ababa c:L:tsx:S,b, ,g:@v@${v}@:Q}
|
|
|
|
|
|
|
|
# A final :M* modifier applies the :ts separator again, though.
|
|
|
|
@${PRINT} ':ts :S :@ :M => '${a ababa c:L:tsx:S,b, ,g:@v@${v}@:M*:Q}
|