def Zsh.esc
import cli@0.2.0.0/cli.bend as Cliimport Base
6161# Text in an _arguments spec or a _describe entry, with \, [, ] and :
6162# backslash-escaped (P5).
6163def Zsh.esc(s: String) -> String:
6164 match s:
6165 case SNil{}: SNil{}
6166 case SCon{Chr{92}, tail}: String.append("\\\\", Zsh.esc(tail))
6167 case SCon{Chr{91}, tail}: String.append("\\[", Zsh.esc(tail))
6168 case SCon{Chr{93}, tail}: String.append("\\]", Zsh.esc(tail))
6169 case SCon{Chr{58}, tail}: String.append("\\:", Zsh.esc(tail))
6170 case SCon{c, tail}: SCon{c, Zsh.esc(tail)}