1*6a7405f5SSimon J. Gerraty# $NetBSD: varmod-order.mk,v 1.18 2025/01/11 20:54:46 rillig Exp $ 22c3632d1SSimon J. Gerraty# 312904384SSimon J. Gerraty# Tests for the :O variable modifier and its variants, which either sort the 412904384SSimon J. Gerraty# words of the value or shuffle them. 52c3632d1SSimon J. Gerraty 612904384SSimon J. GerratyWORDS= one two three four five six seven eight nine ten 712904384SSimon J. GerratyNUMBERS= 8 5 4 9 1 7 6 10 3 2 # in English alphabetical order 82c3632d1SSimon J. Gerraty 912904384SSimon J. Gerraty.if ${WORDS:O} != "eight five four nine one seven six ten three two" 1012904384SSimon J. Gerraty. error ${WORDS:O} 112c3632d1SSimon J. Gerraty.endif 122c3632d1SSimon J. Gerraty 13*6a7405f5SSimon J. Gerraty# expect+1: Bad modifier ":OX" 1412904384SSimon J. Gerraty_:= ${WORDS:OX} 152c3632d1SSimon J. Gerraty 16*6a7405f5SSimon J. Gerraty# expect+1: Bad modifier ":OxXX" 1712904384SSimon J. Gerraty_:= ${WORDS:OxXX} 1812904384SSimon J. Gerraty 19*6a7405f5SSimon J. Gerraty# expect+1: Unclosed expression, expecting '}' for modifier "O" 2012904384SSimon J. Gerraty_:= ${WORDS:O 21*6a7405f5SSimon J. Gerraty# expect+1: Unclosed expression, expecting '}' for modifier "On" 2212904384SSimon J. Gerraty_:= ${NUMBERS:On 23*6a7405f5SSimon J. Gerraty# expect+1: Unclosed expression, expecting '}' for modifier "Onr" 2412904384SSimon J. Gerraty_:= ${NUMBERS:Onr 2512904384SSimon J. Gerraty 2612904384SSimon J. Gerraty# Shuffling numerically doesn't make sense, so don't allow 'x' and 'n' to be 2712904384SSimon J. Gerraty# combined. 2812904384SSimon J. Gerraty# 29*6a7405f5SSimon J. Gerraty# expect+1: Bad modifier ":Oxn" 3012904384SSimon J. Gerraty.if ${NUMBERS:Oxn} 3112904384SSimon J. Gerraty. error 3212904384SSimon J. Gerraty.else 3312904384SSimon J. Gerraty. error 3412904384SSimon J. Gerraty.endif 3512904384SSimon J. Gerraty 3612904384SSimon J. Gerraty# Extra characters after ':On' are detected and diagnosed. 3712904384SSimon J. Gerraty# 38*6a7405f5SSimon J. Gerraty# expect+1: Bad modifier ":On_typo" 3912904384SSimon J. Gerraty.if ${NUMBERS:On_typo} 4012904384SSimon J. Gerraty. error 4112904384SSimon J. Gerraty.else 4212904384SSimon J. Gerraty. error 4312904384SSimon J. Gerraty.endif 4412904384SSimon J. Gerraty 4512904384SSimon J. Gerraty# Extra characters after ':Onr' are detected and diagnosed. 4612904384SSimon J. Gerraty# 47*6a7405f5SSimon J. Gerraty# expect+1: Bad modifier ":Onr_typo" 4812904384SSimon J. Gerraty.if ${NUMBERS:Onr_typo} 4912904384SSimon J. Gerraty. error 5012904384SSimon J. Gerraty.else 5112904384SSimon J. Gerraty. error 5212904384SSimon J. Gerraty.endif 5312904384SSimon J. Gerraty 5412904384SSimon J. Gerraty# Extra characters after ':Orn' are detected and diagnosed. 5512904384SSimon J. Gerraty# 56*6a7405f5SSimon J. Gerraty# expect+1: Bad modifier ":Orn_typo" 5712904384SSimon J. Gerraty.if ${NUMBERS:Orn_typo} 5812904384SSimon J. Gerraty. error 5912904384SSimon J. Gerraty.else 6012904384SSimon J. Gerraty. error 6112904384SSimon J. Gerraty.endif 6212904384SSimon J. Gerraty 6312904384SSimon J. Gerraty# Repeating the 'n' is not supported. In the typical use cases, the sorting 6412904384SSimon J. Gerraty# criteria are fixed, not computed, therefore allowing this redundancy does 6512904384SSimon J. Gerraty# not make sense. 6612904384SSimon J. Gerraty# 67*6a7405f5SSimon J. Gerraty# expect+1: Bad modifier ":Onn" 6812904384SSimon J. Gerraty.if ${NUMBERS:Onn} 6912904384SSimon J. Gerraty. error 7012904384SSimon J. Gerraty.else 7112904384SSimon J. Gerraty. error 7212904384SSimon J. Gerraty.endif 7312904384SSimon J. Gerraty 7412904384SSimon J. Gerraty# Repeating the 'r' is not supported as well, for the same reasons as above. 7512904384SSimon J. Gerraty# 76*6a7405f5SSimon J. Gerraty# expect+1: Bad modifier ":Onrr" 7712904384SSimon J. Gerraty.if ${NUMBERS:Onrr} 7812904384SSimon J. Gerraty. error 7912904384SSimon J. Gerraty.else 8012904384SSimon J. Gerraty. error 8112904384SSimon J. Gerraty.endif 8212904384SSimon J. Gerraty 8312904384SSimon J. Gerraty# Repeating the 'r' is not supported as well, for the same reasons as above. 8412904384SSimon J. Gerraty# 85*6a7405f5SSimon J. Gerraty# expect+1: Bad modifier ":Orrn" 8612904384SSimon J. Gerraty.if ${NUMBERS:Orrn} 8712904384SSimon J. Gerraty. error 8812904384SSimon J. Gerraty.else 8912904384SSimon J. Gerraty. error 9012904384SSimon J. Gerraty.endif 912c3632d1SSimon J. Gerraty 928c973ee2SSimon J. Gerraty 938c973ee2SSimon J. Gerraty# If a modifier that starts with ':O' is not one of the known sort or shuffle 948c973ee2SSimon J. Gerraty# forms, it is a parse error. Several other modifiers such as ':H' or ':u' 958c973ee2SSimon J. Gerraty# fall back to the SysV modifier, for example, ':H=new' is not the standard 968c973ee2SSimon J. Gerraty# ':H' modifier but instead replaces a trailing 'H' with 'new' in each word. 978c973ee2SSimon J. Gerraty# There is no such fallback for the ':O' modifiers. 988c973ee2SSimon J. GerratySWITCH= On 99*6a7405f5SSimon J. Gerraty# expect+1: Bad modifier ":On=Off" 1008c973ee2SSimon J. Gerraty.if ${SWITCH:On=Off} != "Off" 1018c973ee2SSimon J. Gerraty. error 1028c973ee2SSimon J. Gerraty.else 1038c973ee2SSimon J. Gerraty. error 1048c973ee2SSimon J. Gerraty.endif 1058c973ee2SSimon J. Gerraty 1062c3632d1SSimon J. Gerratyall: 107