# LibTmuxWorkspace.run_before_script

- **Module:** LibTmuxWorkspace
- **Package:** LibTmuxWorkspace
- **Language:** Julia
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-julia/blob/f3da513be1225d36d5854cd8db5972c01857578e/packages/LibTmuxWorkspace/src/script.jl#L103
- **Page:** https://libtmux.org/en/julia/latest/workspace/reference/libtmuxworkspace-run_before_script/

```
run_before_script(
    text::AbstractString;
    base_directory,
    start_directory,
    env,
    timeout,
    cancel,
    on_output,
    max_output_bytes,
    max_error_bytes
)
```

## Methods

Execute shlex-style argv without implicit shell evaluation. Relative executable paths containing `/` resolve from the configuration base; bare names use PATH. Explicit `/bin/sh -c` remains an intentional shell command. Pipes are drained concurrently with bounded captures; `on_output(stream, bytes)` receives owned chunks and must return promptly. Its calls are serialized across both streams.

```julia
run_before_script(text; base_directory, start_directory=base_directory,
                  env=ENV, timeout=0.9, cancel=nothing, on_output=nothing,
                  max_output_bytes=65536, max_error_bytes=65536)
```



Cancellation/deadline kill the directly owned process and its still-owned POSIX process group. The direct child is reaped on every path. Descendants that leave the group, or outlive successful script exit with redirected output, are external script effects; their exit is not established. The same monotonic deadline bounds inherited open pipes after direct-child exit. No output appears in errors.

## Parameters

- `text` (`AbstractString`)
- `base_directory` (`AbstractString`)
- `start_directory` (`AbstractString`)
  Default: `base_directory`.
- `env` (`AbstractDict`)
  Default: `ENV`.
- `timeout` (`Real`)
  Default: `0.9`.
- `cancel`
  Default: `nothing`.
- `on_output`
  Default: `nothing`.
- `max_output_bytes` (`Int`)
  Default: `65536`.
- `max_error_bytes` (`Int`)
  Default: `65536`.
