tdenniston / bish

Bish is a language that compiles to Bash. It's designed to give shell scripting a more comfortable and modern feel.
MIT License
1.48k stars 36 forks source link

Rethrowing functions #29

Closed egorsmkv closed 9 years ago

egorsmkv commented 9 years ago

If you compile this file, the function println will be generated twice.

I think that it generates the assert function to initialize the standard library. Need to do accounting functions created so that they generate only once.

egorsmkv commented 9 years ago

@tdenniston This is normal, so the standard library is compiled?

function bish_print () {
    echo -ne "$1";
}

function bish_println () {
    echo -e "$1";
}

function bish_exists () {
    test -e $1;
    echo $(bish_success); exit;
}

function bish_success () {
    rc=$(echo $?);
    if [[ $rc -eq 0 ]]; then
        echo 1; exit;
    else
        echo 0; exit;
    fi;
}

function bish_ls () {
    echo "$(ls)"; exit;
}

function bish_cd () {
    cd $1;
}

function bish_cwd () {
    echo "$(pwd)"; exit;
}

function bish_abspath () {
    echo "$(cd $1 ; pwd)"; exit;
}

function bish_assert () {
    if [[ $1 -eq 0 ]]; then
        bish_println "Assertion failed.";
        exit 1;
    fi;
}

function bish_main () {
}

function bish_println () {
    echo -e "$1";
}

function bish_success () {
    rc=$(echo $?);
    if [[ $rc -eq 0 ]]; then
        echo 1; exit;
    else
        echo 0; exit;
    fi;
}

bish_main;
egorsmkv commented 9 years ago

@tdenniston That's better.