#!/usr/bin/ucode

// Loads the library from its precompiled copy when core/bytecode.uc can keep
// one, and runs the command through service/cli.uc.

const SOURCE_LIB_DIR = "/usr/lib/forkop";

function library_dir() {
    let configured = getenv("FORKOP_LIB");
    if (configured != null && configured != "")
        return configured;
    try {
        return loadfile(SOURCE_LIB_DIR + "/core/bytecode.uc")().refresh();
    }
    catch (e) {
        return SOURCE_LIB_DIR;
    }
}

let library = library_dir();
unshift(REQUIRE_SEARCH_PATH, library + "/*.uc");
exit(require("service.cli").main(ARGV, library));
