Subject: | `hostname --fqdn` isn't portable |
The hostname(1) command doesn't behave the same way on different Unix systems. Therefore, executing `hostname --fqdn`without checking the current system is quite hazardous.
The problem is that on Solaris systems hostname(1) does not expect any options at all and take the first argument it sees as the new hostname. So, `hostname --fqdn` will set the hostname to "--fqdn", which has some infortunate consequences. hostname(1) on Solaris behaves this way from at least SunOS 2.6 to 2.9.
FYI, on Mac OS X/Darwin, hostname(1) will always returns the FQDN unless called with the option -s. Option --fqdn does not generate an error though. On IRIX (5.3 to 6.3) hostname(1) behaves the same way (prints the FQDN unless given the -s option), but I can't say if it will just silently drop the --fqdn option.