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

 
 

bug #59261: Nonsensical conditional in hostname.REPLACEMENT

Submitted by:  Tristan Miller <psychonaut>
Submitted on:  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

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

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:

    HOSTNAME=manifold
    FULL_HOSTNAME=manifold.algebra.com

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

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:
   
   
Comment:
   

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)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

     

     

    No changes have been made to this item

    Back to the top


    Powered by Savane 3.6