;-escape list implicit unescaping
Example:
set(l1 "")
# does not work on empty list because empty string and list containing one empty string are not distinguish from each other
#list(APPEND l1 "")
#list(APPEND l1 "")
# SOLUTION: declare list with 2 empty strings and remove them at the end instead, GO!
set(l1 ";")
list(APPEND l1 "\\111\;222")
list(APPEND l1 "\\333\;444")
list(APPEND l1 "\\555\;666")
list(LENGTH l1 l1_len)
message("[${l1_len}] l1=`${l1}`")
set(l2 "${l1}")
list(LENGTH l2 l2_len)
message("[${l2_len}] l2=`${l2}` - OK")
set(l3 "${l1}")
list(LENGTH l3 l3_len)
message("[${l3_len}] l3=`${l3}` - OK")
# removing #1
list(REMOVE_AT l1 0 1)
list(LENGTH l1 l1_len)
message("[${l1_len}] l1=`${l1}`")
if (NOT l1 STREQUAL "\\111\;222;\\333\;444;\\555\;666")
message(" - WTF: 5-2=6?")
endif()
# removing #2
list(SUBLIST l2 2 -1 l2)
list(LENGTH l2 l2_len)
message("[${l2_len}] l2=`${l2}`")
if (NOT l2 STREQUAL "\\111\;222;\\333\;444;\\555\;666")
message(" - WTF: 5-2=6?")
endif()
Output:
[5] l1=`;;\111\;222;\333\;444;\555\;666`
[5] l2=`;;\111\;222;\333\;444;\555\;666` - OK
[5] l3=`;;\111\;222;\333\;444;\555\;666` - OK
[6] l1=`\111;222;\333;444;\555;666`
- WTF: 5-2=6?
[6] l2=`\111;222;\333;444;\555;666`
- WTF: 5-2=6?
Edited by Andrey