Use POSIX-compliant uname instead of hostname#14
Open
kissge wants to merge 5 commits intognachman:mainfrom
Open
Use POSIX-compliant uname instead of hostname#14kissge wants to merge 5 commits intognachman:mainfrom
kissge wants to merge 5 commits intognachman:mainfrom
Conversation
… slow. Issue 10646.
…e64 very slow. Issue 10646." This reverts commit 546b8fe.
Owner
|
Sorry for the delay in getting to this PR. The hostname is used by the scp feature to create a new connection, so it needs to be a fully qualified domain name. On Ubuntu 18 I get this: The problem you raise is real—especially the performance concern!—and I'm definitely interested in a solution, but I'm not sure what that might look like. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
shell_intergration scripts depends on hostname(1), assuming it's available on every host including remote ones (over SSH).
However that's not the case with some Linux environments.
For example, in Arch Linux you need install
inetutilspackage.This leads to seeing the following error message every time I login to such hosts:
shell_integration/zsh:164: command not found: hostname.Solution
This PR aims to fix the problem by simply replacing all hostname(1) calls to uname(1).
This makes two differences:
uname -nis available on practically every UNIX-like system including FreeBSD, NetBSD, and OpenBSD.uname -nis faster because it's simply invoking uname(2) syscall2. On the other hand,hostname -fuses gethostbyname(3)3 which causes name server lookups every time.Discussion
This is my first contribution to your repository.
Please forgive me if it's not your taste; I'd appreciate if you can help improving this PR.
Thanks for this lovely product!
Footnotes
https://pubs.opengroup.org/onlinepubs/009695299/utilities/uname.html ↩
https://github.com/coreutils/coreutils/blob/9581c4b59d2e11cd090613cd300a833b4441d2b5/src/uname.c#L299-L305 ↩
https://git.savannah.gnu.org/cgit/inetutils.git/tree/src/hostname.c?id=c1b8d134d542e7e81c3dcd6adbd05305cb2c78df#n290 ↩