# Clearing inherited variables in System.cmd

Passing `env: []` to `System.cmd/3` does not clear the child environment.

```elixir
System.put_env("VENDOR_TOKEN", "development")

System.cmd("sh", ["-c", ~s(printf %s "$VENDOR_TOKEN")], env: [])
#=> {"development", 0}

System.cmd("sh", ["-c", ~s(printf %s "$VENDOR_TOKEN")],
  env: [{"VENDOR_TOKEN", nil}]
)
#=> {"", 0}
```

The child inherits its parent environment. `:env` changes only the keys you provide, so an empty list leaves it alone.

Use `nil` for a token or other value that must not reach a subprocess. Otherwise, a local credential can make a test or external command succeed by accident.

[System.cmd/3 documentation](https://hexdocs.pm/elixir/System.html#cmd/3)


---

Created by: almirsarajcic
Date: September 17, 2026
URL: https://elixirdrops.net/d/KpFePAjf
