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

"bish_success: command not found" when using exists() #5

Closed richq closed 9 years ago

richq commented 9 years ago

Seems like when functions from StdLib are pulled in, the pulling in isn't recursive. Maybe just include the lot, regardless of if they are used or not? Bloat for the win!

The following example:

if (exists("file-that-does-not-exist")) {
    print("file exists");
}

gives this, which is missing bish_success function.

function bish_main () {
    if [[ $(bish_exists "file-that-does-not-exist") ]]; then
        bish_print "file exists";
    fi;
}

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

function bish_print () {
    echo $1;
}

bish_main;
tdenniston commented 9 years ago

Hmm... I need to fix the link_stdlib function for this. I probably broke this with c3f0169.

tdenniston commented 9 years ago

Fixed with commit 036eabd.

tdenniston commented 9 years ago

By the way, the shorthand syntax for using function calls as booleans/values does not work yet. This:

if (func()) {
    do_something();
}

Should be implemented like this:

if (func() == true) {
    do_something();
}

Don't worry, it's on my to do list!

richq commented 9 years ago

OK, got it. Thanks.