---
name: "setenviron"
section: "3"
platform: "macos"
package: "ksh"
version: "42"
release: "macOS 26.5"
platforms: ["macos"]
url: "https://new.carta.tech/setenviron"
---

# setenviron(3)

set environment value

## NAME

setenviron - set environment value

## SYNOPSIS

```
#include <ast.h>
char*     setenviron(const char* key);
```

## DESCRIPTION

$1$2setenvironsetenvironsetenvironsetenvironsetenvironsetenvironsetenvironsetenviron controls environment *name=value* pairs. $1$2setenviron(setenviron(setenviron(setenviron(setenviron(setenviron(setenviron(setenviron( adds *name* to the environment and returns a pointer to a [*strdup*(3)](/strdup/3.md) copy of *name=value*. $1$2setenviron(setenviron(setenviron(setenviron(setenviron(setenviron(setenviron(setenviron( removes *name* from the environment and returns the empty string. $1$2setenviron(0)setenviron(0)setenviron(0)setenviron(0)setenviron(0)setenviron(0)setenviron(0)setenviron(0) reserves a few slots in an internal array and is usually called by a parent process that expects many children. 0 is returned on error. $1$2setenvironsetenvironsetenvironsetenvironsetenvironsetenvironsetenvironsetenviron preserves the [*ksh*(1)](/ksh/1.md) convention of $1$2\_\_\_\_\_\_\_\_ as the first environment variable name.

## SEE ALSO

[env(1)](/env/1.md), exec(2)

## BUGS

POSIX will eventually settle on an interface. It has already picked a few of the names we did in .2 drafts. This is about the third name change for ours.
