JanetDocsI'm feeling luckyGithub sign in

os/execute



    cfunction

    (os/execute args &opts flags env)
    
    Execute a program on the system and pass it string arguments. Flags is
    a keyword that modifies how the program will execute.
    
      :e - enables passing an environment to the program. Without :e, the
    current environment is inherited.
      :p - allows searching the current PATH for the binary to execute.
    Without this flag, binaries must use absolute paths.
    
    env is a table or struct mapping environment variables to values.
    Returns the exit status of the program.


2 examplesSign in to add an example
Loading...
(os/execute
  @("/usr/bin/bash" "-c" "set")
  :e
  @{"SOME" "value"
    "OTHER" "one"})
# => 0

# execute bash and prints environment variables
# which contains SOME=value and Other=one
goldenHairDafo
(os/execute
  @("python" "-c" "print('Hello Janet'"))
  :p) 
# => 0

# execute python -c "print('Hello Janet') while
# searching path on the current path
goldenHairDafo