I know how to split a string on a printable separator character; e.g. if the separator is ,:FOO='x,y,z'printf %s\n ${(s:,:)FOO}xyzBut what if the separator is a control character, such as \034?  For exampleFOO=$'x\034y\034z'I've tried putting everything I can think of between the :'s in the (s:...:) qualifier, including \034, $'\034', and several others, but nothing I've tried splits the original string.(One solution that is not acceptable would be to perform a global substitution that replaces all occurrences of the original delimiter with, for example, ,, and then to split the resulting string with (s:,:).  The reason for ruling out such a solution is that the rational for using `$'\034' as delimiter in the first place is to reduce the chance that the delimited text would contain a delimiter.  Replacing the original delimiter with a printable one completely defeats this rationale.)EDIT: regarding putting the delimiter in a variable, I tried the following test script#!/usr/bin/env zshDELIM=$'\034'FOO=x${DELIM}y${DELIM}zBAR=(${(ps:$DELIM:)FOO})printf %s\n $BARBAZ=(${(ps:\034:)FOO})printf %s\n $BAZThe output I get isx^\y^\zxyz(where I've used ^\ to simulate the appearance of the printed \034 on my terminal.)FWIW, my shell version is zsh 5.0.7 (x86_64-pc-linux-gnu).
How to split a string on a control character?
zsh;string
You need to add p flag to make the following flag recognize escape sequences:$ FOO=$'x\034y\034z'$ print -rl -- ${(ps:\034:)FOO}xyzIf you don't want to hard-code the delimiter (require version >= 5.0.8):$ DELIM=$'\034'print -rl -- ${(ps:$DELIM:)FOO}