Skip to content

Commit a217468

Browse files
vegerotfacebook-github-bot
authored andcommitted
fix(scm-prompt): suppress cd output (#985)
Summary: If a user has a `chpwd` hook that prints output, it will be prepended to the `dir` variable which breaks the prompt. This change suppresses the output of `cd` to prevent this. Alternatively I considered doing `cd -q` to skip running the chpwd hook, but decided against it. Pull Request resolved: #985 Test Plan: ```zsh $ zsh --no-rcs $ source ~/workspace/github.com/facebook/sapling/eden/scm/contrib/scm-prompt.sh && _scm_prompt # things should be fine $ say_hi() { echo hello } && chpwd_functions+=(say_hi) && _scm_prompt ``` prior to this commit, the prompt would be broken. After this commit, it should be fine. Background: in my particular case, I have a `chpwd` hook that [sources custom scripts](https://github.com/vegerot/dotfiles/blob/032f88715fa2911bec6b3c09aa012145bb1dae7e/.zshrc#L250-L252) depending on the directory, and will tell me if it does so. This was breaking the prompt, so I added this change to fix it. Reviewed By: quark-zju Differential Revision: D66384725 fbshipit-source-id: e03d18887a27fc6c55da1dc7347eacf0fa38cde7
1 parent 0611423 commit a217468

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

eden/scm/contrib/scm-prompt.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ _scm_prompt() {
257257
fi
258258
[[ "$dir" = "/" ]] && break
259259
# portable "realpath" equivalent
260-
dir="$(builtin cd -P "$dir/.." && builtin echo "$PWD")"
260+
dir="$(builtin cd -P "$dir/.." >/dev/null && builtin echo "$PWD")"
261261
done
262262

263263
if [[ -n "$br" ]]; then

0 commit comments

Comments
 (0)