Creating a personal theme: 'face' wrong_argument count

Hello all,

So I’m trying to create a Monokai theme for Kakoune. Looking around at other people’s themes, I made this

# Classic Monokai Theme for Kakoune

evaluate-commands %sh{










    echo "
        # Code
        face global value          ${purple}
        face global type           ${cyan}
        face global variable       ${white}
        face global identifier     ${orange}
        face global module         ${blue}
        face global function       ${green}
        face global string         ${yellow}
        face global keyword        ${magenta}
        face global operator       ${green}
        face global attribute      ${magenta}
        face global comment        ${gray}
        face global documentation  ${dark_cyan}
        face global meta           ${dark_blue}
        face global builtin        default+b

        # Markup
        face global title         ${red}+b
        face global header        ${magenta}+b
        face global bold          default,${orange}+ba
        face global italic        default,${cyan}+ia
        face global underline     default,${blue}+ufa
        face global strikethrough default+bfg
        face global mono          ${green}
        face global block         ${purple}
        face global link          ${cyan}+u
        face global bullet        ${dark_cyan}
        face global list          ${dark_cyan}

        # Builtin faces
        face global Default            ${white},${black}

        face global PrimarySelection   ${gray},${white}+bfg
        face global SecondarySelection ${gray},${white}+fg

        face global PrimaryCursor      ${black},${magenta}+bfg
        face global SecondaryCursor    ${black},${blue}+fg
        face global PrimaryCursorEol   ${black},${purple}+bfg
        face global SecondayCursorEol  ${black},${purple}+fg

        face global LineNumbers        ${bgtwo}
        face global LineNumberCursor   ${yellow}+b

        face global MenuForeground     ${dark_blue}
        face global MenuBackground     default,${bgtwo}
        face global MenuInfo           ${orange}+i

        face global Information        ${green}

        face global Error              ${black},${red}+fg

        face global StatusLine         ${dark_cyan},${bgtwo}
        face global StatusLineMode     ${dark_cyan}
        face global StatusLineInfo     ${dark_cyan}
        face global StatusLineValue    ${cyan}
        face global StatusCursor       ${black},${white+bg}

        face global Prompt             ${purple},${bgtwo}

        face global MatchingChar       default,${red}+b

        face global Whitespace         ${black}+f

        face global BufferPadding      default,${bgtwo}+f

        face global WrapMarker         ${bgtwo}+f

This is in $XDG_CONFIG_HOME/kak/colors/monokai.kak, however after putting colorscheme monokai in my kakrc, I get this error:

/home/my_user/.config/kak/colors/monokai.kak:3:1: 'evaluate-commands' 5:9: 'face' wrong argument count
~/.config/kak/ui.kak:17:1: 'colorscheme' 1:2: 'evaluate-commands' 1:1: 'source' 3:1: 'evaluate-commands' 5:9: 'face' wrong argument count

But I’m not sure where it’s having an issue?

Could I get a second pair of eyes on this?

Kakoune version: v2020.01.16-129-gc585107a

The error message says:

'evaluate-commands' 5:9: 'face' wrong argument count

If we look at line 5 (and column 9) of the output produced by the %sh{} block (luckily, it’s all produced by a single echo command, so it’s easy to find), we see:

face global variable ${white}

…and sure enough, there’s no definition of “white”, so that line winds up invoking the face command with only two arguments.

You might want to put set -u at the top of your %sh{} block in future, to have the shell automatically fail when you try to use a shell-variable that was never defined.

Ah I see my mistakes.

Is set -u is something to keep in mind when writing %sh{} blocks?

Is set -u is something to keep in mind when writing %sh{} blocks?

POSIX shell is a mercurial language; sometimes it makes things really easy, sometimes it savagely and unexpectedly bites you. Some people will refer to set -euf -o pipefail as unofficial strict mode, but pure-POSIX shell does not support -o pipefail (it’s a bash-ism) and there are still corner-cases that mean set -e doesn’t work quite the way most people expect.

But that and ShellCheck make it easier to write reliable shell scripts.