This repository has been archived by the owner on May 1, 2024. It is now read-only.
Fix bug that causes status line to be empty if Unix username has spaces #84
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The current implementation for extracting the current working directory (cwd) fails for Unix when the username has a space. This causes the cwd string to be empty, which leads to a completely empty status line.
Specifically,
awk
retrieves the 4th field from thelsof
output, but when the username has a space, cwd is actually the 5th, because of the additional whitespace.The submitted patch circumvents this by using the
-F
option forlsof
so that columns are returned as rows for increased machine-readability. The correct field is filtered by process id (-p ${pid}
) and field identifier (-d cwd
), where the-a
option ensures the logical and of these filters. The output oflsof
is then grepped to get the field with identifiern
(name) as the first character. This identifier is finally removed withcut
, so that the remaining string is the current working directory.Tested with Hyper 2.0.0 on MacOS High Sierra 10.13.6