bugSTUMP - Bugs: bug #59261, Nonsensical conditional in...


You are not allowed to post comments on this tracker with your current authentication level.

bug #59261: Nonsensical conditional in hostname.REPLACEMENT

Submitter:  Tristan Miller <psychonaut>
Submitted:  Tue 13 Oct 2020 12:28:22 PM UTC
Category:  None Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open
* Mandatory Fields

Add a New Comment (Rich Markup)

Comment Type & Canned Response:
       No canned response available


Thu 15 Oct 2020 04:30:45 PM UTC, comment #1: 

The:  if [ "x$1" = "-f" ] ; then

Within that script it kind of looks like an attempt at one of the usual workarounds for older Bourne Shell problems where [ "$1" = "-f" ]  would error out if $1 ever turned out to be empty.   They likely intended to have  written [ "x$1" != "x-f" ]

However, this logic flow of not defaulting to "-f" is strange for the hostname command,  and if meant to "replace" hostname it makes more sense to just have an unconditional:   echo $FULL_HOSTNAME

The hostname system utility does not originally have reliable  standardized semantics and has different available command line options and choice of whether you are printing the FQDN or Host portion only by default.. across different operating systems; on some OSes executing "hostname" with no options would print the Fully-Qualified Domain matching POSIX gethostname() or or uname nodename.. on others Hostname  defaults to trimming off the domain portion of the FQDN.

Even on modern FreeBSD, etc, however the -f option is redundant as  "hostname -f"  is currently the default on modern OS, and  "hostname -s" the opposite.

Mike Keith <mysidia>
Tue 13 Oct 2020 12:28:22 PM UTC, original submission:  

The hostname.REPLACEMENT script, which is supposed to be a "drop-in replacement for hostname" on certain BSD-derived systems, consists of the following code:


    if [ "x$1" = "-f" ] ; then
      echo $HOSTNAME
      echo $FULL_HOSTNAME

However, the comparison in the conditional can never be true.  Quite possibly this is a bug, but without knowing more about the problem with BSD hostname that this script is supposed to work around, I can't be sure.  (Maybe Igor really did want the script to always output $FULL_HOSTNAME, but in that case why have a conditional at all, and why instruct the user to declare both HOSTNAME and FULL_HOSTNAME?)

Tristan Miller <psychonaut>
Project Administrator


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by mysidia (Posted a comment)
  • -email is unavailable- added by psychonaut (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.





    No changes have been made to this item

    Back to the top

    Powered by Savane 3.9