Re: [PATCH v2] send-email: try to get fqdn by running hostname --fqdn on Linux and macOS
- From
Aditya Garg <gargaditya08@live.com>
- Date
- May 12, 2025, 07:49 UTC
- Message-ID
- <PN3PR01MB959732CE8360446CD4E0A184B897A@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM>
- In-Reply-To
- <D9U0KAX6KVXK.WCY7YGX2Q0A5@swagemakers.org>
Show 34 quoted lines
> On 12 May 2025, at 1:16 PM, Julian Swagemakers <julian@swagemakers.org> wrote: > > On Sat May 10, 2025 at 9:37 AM CEST, Aditya Garg wrote: >> `hostname` is a popular command available on both Linux and macOS. As >> per the man-page[1], `hostname --fqdn` command returns the fully >> qualified domain name (FQDN) of the system. > > There are multiple implementations of the hostname command, and they > don't all support `--fqdn`. For example this will not work on Alpine > Linux as well as macOS. > > macOS: > > $ hostname --fqdn > hostname: illegal option -- - > usage: hostname [-f] [-s | -d] [name-of-host] > > Alpine: > > $ hostname --fqdn > hostname: unrecognized option: fqdn > BusyBox v1.37.0 (2025-01-17 18:12:01 UTC) multi-call binary. > > Usage: hostname [-sidf] [HOSTNAME | -F FILE] > > Show or set hostname or DNS domain name > > -s Short > -i Addresses for the hostname > -d DNS domain name > -f Fully qualified domain name > -F FILE Use FILE's content as hostname > > All seem to support `-f` though, maybe that would be the better option.
Sure. I was using -f before, but thought --fqdn would be more intuitive for anyone reading the code. Didn't know its not supported every where.