Skip to content

Instantly share code, notes, and snippets.

@sogaiu
Last active October 12, 2023 09:12
Show Gist options
  • Save sogaiu/cadaae38a66dbbd480141496af04f7af to your computer and use it in GitHub Desktop.
Save sogaiu/cadaae38a66dbbd480141496af04f7af to your computer and use it in GitHub Desktop.
sh/exec-slurp via janet_dostring (assuming spork is installed)
// build:
//
// gcc -O0 -g main.c -I$HOME/.local/include -L$HOME/.local/lib -ljanet
// run:
//
// export LD_LIBRARY_PATH=$HOME/.local/lib
// ./a.out
#include "janet.h"
#include <stdio.h>
int main() {
JanetTable *env;
janet_init();
env = janet_core_env(NULL);
int status =
janet_dostring(env,
"(import spork/sh) (pp (sh/exec-slurp `uname`))",
"source", NULL);
printf("result: %d\n", status);
janet_deinit();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment