# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           github 1.0

github.setup        akinomyoga ble.sh 0.4.0-devel3 v
fetch.type          git

description         Bash Line Editor (${name}) is a command line editor written in pure Bash which replaces the default GNU Readline.
long_description    ${description}
license             BSD

platforms           any
maintainers         {cal @neverpanic} openmaintainer
categories          sysutils shells

post-fetch {
    system -W ${worksrcpath} "git submodule update --init --recursive"
}

depends_build-append \
                    port:gawk

use_configure       no

build.type          gnu
use_parallel_build  no

post-destroot {
    xinstall -m 644 \
        ${filespath}/_package.bash.in \
        ${destroot}${prefix}/share/blesh/lib/_package.bash
    reinplace \
        "s|@sudo@|[expr {${sudo_user} != "" ? "sudo" : ""}]|g; s|@prefix@|$prefix|g" \
        ${destroot}${prefix}/share/blesh/lib/_package.bash
}

destroot.args-append \
                    PREFIX=${prefix}

notes "\
To enable ${name} in interactive sessions of bash, add the following line at the top of your ~/.bashrc:\n\
    \t\[\[ $- == *i* ]] && source -- ${prefix}/share/blesh/ble.sh --attach=none\n\
and the following line at the end of your ~/.bashrc:\n\
    \t\[\[ ! \${BLE_VERSION-} ]] || ble-attach"
