Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using janet_dostring with os/execute evaluates to nil #1307

Closed
iacore opened this issue Oct 12, 2023 · 2 comments
Closed

Using janet_dostring with os/execute evaluates to nil #1307

iacore opened this issue Oct 12, 2023 · 2 comments

Comments

@iacore
Copy link
Contributor

iacore commented Oct 12, 2023

Reproduction: https://gist.github.com/iacore/6acbb2d98403e468c35dd835518b9be5

Related to #926

This may be a spork bug or a janet bug.

@iacore iacore changed the title Using janet_dostring with sh/exec-slurp fail to evaluate. Using janet_dostring with sh/exec-slurp evaluates to nil Oct 12, 2023
@sogaiu
Copy link
Contributor

sogaiu commented Oct 12, 2023

May be it's not spork as compiling and executing the following:

// 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 out;
  
  status =
    janet_dostring(env,
                   "(os/execute [`ls`] :px)",
                   "source", &out);

  printf("os/execute status: %d\n", status);

  janet_gcroot(out);

  printf("janet_type: %d\n", janet_type(out));

  printf("\n");
  
  janet_deinit();
}

ends with the output:

os/execute status: 0
janet_type: 1

The expected output is:

os/execute status: 0
janet_type: 0

That is, I expect a number JANET_NUMBER (0) but I'm seeing nil JANET_NIL (1).

Janet 1.31.0-cb25a2ec linux/x64/gcc - '(doc)' for help
repl:1:> (os/execute ["ls"] :px)
...
0

@iacore iacore changed the title Using janet_dostring with sh/exec-slurp evaluates to nil Using janet_dostring with os/execute evaluates to nil Oct 12, 2023
@iacore
Copy link
Contributor Author

iacore commented Oct 12, 2023

e3f4142 seems to have fixed this. Can no longer reproduce.

@iacore iacore closed this as completed Oct 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants