Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: prefer id over whoami #114

Merged
merged 1 commit into from
Dec 30, 2024
Merged

Conversation

anntnzrb
Copy link
Contributor

@anntnzrb anntnzrb commented Dec 23, 2024

Replace whoami with id -un for broader compatibility, as id -un is POSIX-compliant, widely available, and reliable. It produces the same output as whoami across environments without issues.

References


Edit 1:
Main source: Linux whoami command and the id command of its successor

The id command of whoami ’s replacement is defined by the POSIX standard, and the implementation is done by various operating system vendors.
Because the POSIX standard is a member of the IEEE standard, the id command is more standardized than the whoami command as a product of standardization, and as long as the operating system supports the POSIX standard, there will be an id command. Therefore, in daily operations, using the standardized id command is more recommended.

@srid
Copy link
Member

srid commented Dec 24, 2024

cc @shivaraj-bh

I thought whoami is the more reliable one?

See juspay/omnix#253

@anntnzrb
Copy link
Contributor Author

Edited to add main source.

@srid srid requested a review from shivaraj-bh December 24, 2024 13:30
@srid
Copy link
Member

srid commented Dec 24, 2024

I thought whoami is the more reliable one?

See juspay/omnix#253

Ah, n/m. I misunderstood. whoami is more reliable than $USER (which is why a99e8d3). I don't think we ever used id.

Out of curiosity, is there a particular environment in which whoami (as used in the main branch of this repo) fails to work for this use case?

@srid srid merged commit e389213 into juspay:main Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants