exec


Description:

public async string exec (string command, string working_dir = "") throws Error

Execute command string in bubblewrap sandbox and return output as string.

This is the main public API for executing commands. It creates and mounts the overlay, builds the bubblewrap command arguments, creates a subprocess, reads stdout and stderr, copies files from overlay to live system, and cleans up the overlay.

The output includes stdout, stderr (if any), and the exit code (if non-zero).

The command is executed via /bin/sh -c, so shell features like pipes, redirects, and command chaining are supported.

Parameters:

command

Command string to execute (e.g., "ls -la" or "cd /path && make")

working_dir

Optional working directory (absolute path). If empty, defaults to first project root.

Returns:

String containing command output (stdout + stderr, with exit code if non-zero)

Exceptions:

Error

if command execution fails, subprocess creation fails, or I/O errors occur