#!/bin/sh

set -e

testz() {
    if test -z "$1"; then
        echo "$2" >&2
        exit 1
    fi
}

testz "$DOTDROP_CONFIG" "DOTDROP_CONFIG is not set"
testz "$1" "No script name provided"

DOTDIR="$(dirname "$DOTDROP_CONFIG")"
cd "$DOTDIR/dotfiles/scripts"

if ! test -f "$1"
then
    pwd
    touch "$1"
    printf '#!/bin/sh\n' > "$1"
    chmod u+x "$1"
fi

kak "$1"
