# Fix accidentally dropping shell environment variable \(\#10105\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/7dbcace8393fa05d53224c75dede3472c2d60802)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 7dbcace8393fa05d53224c75dede3472c2d60802

Requested commit: 7dbcace8393fa05d53224c75dede3472c2d60802

Commit: 7dbcace8393fa05d53224c75dede3472c2d60802

Tree: f7f733b0657ae80827f03504701711904df14c77

Author: Thorsten Ball

Committer: GitHub

## Message

```
Fix accidentally dropping shell environment variable (#10105)

Previously this code would run the changed commend, take its output,
remove the `marker` from the front and then split on `0` byte.

Problem was that `echo` adds a newline, which we did *NOT* skip. So
whatever `env` printed as the first environment variable would have a
`\n` in front of it.

Instead of setting, say, `HOME`, Zed would set `\nHOME`.

This change fixes the issue by switching to `printf '%s' marker`, which
is more portable than using `echo -n`.

This is related to https://github.com/zed-industries/zed/issues/9786 but
I'm not sure yet whether that fixes it.

Release Notes:

- Fixed Zed sometimes missing environment variables from shell in case
they were the first environment variable listed by `/usr/bin/env`.
```

## Parents

- [463c16a402b85c8c9b7e3a0fa3ad25fc69288138](https://git.cafe/gitcafe/zed/commit/463c16a402b85c8c9b7e3a0fa3ad25fc69288138?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/7dbcace8393fa05d53224c75dede3472c2d60802?format=markdown)
