Execute Commands on a Devbox
Isolated vs StatefulShells
By default, every Devbox command is run in an isolated shell. This means that each command is executed in a new shell session, and the state of the shell is not preserved between commands.
Using Stateful Shells
Alternatively, you can use the shell_name
parameter to use a ‘stateful’ shell. This means that the shell will maintain its state across commands including environment variables and working directory.
As an example, let’s create a series of interdependent commands that need to be run in the same shell:
Check initial directory
Create and enter new directory
Verify new working directory is preserved!
Running Commands Synchronously vs Asynchronously
The Runloop shell APIs support both synchronous for immediate results and asynchronous for long-running commands or daemons.
Synchronous Commands
Synchronous commands allow you to run commands and block until you get the command results including stdout, stderr, and the exit code of the command process.
Asynchronous Commands
Asynchronous commands allow you to run commands and not block until you get the command results. This can be useful for long-running commands or daemons such as launching dev servers or background processes.
Launch an async command
Retrieve the Status of the Async Command including the latest output
(Optionally) Kill the async command if needed
Was this page helpful?