[Bug 1276796] Re: bash fails to provide FQDN for PS1 with \H

Rodney Beede 1276796 at bugs.launchpad.net
Tue Feb 18 18:18:34 UTC 2014


I've submitted a bug report up-stream.  A copy of that bug report is
attached.


To: bug-bash at gnu.org,bash at packages.debian.org
Subject: bash fails to provide FQDN for PS1 with \H

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H   -I.  -I../bash -I../bash/include -I../bash/lib  -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall
uname output: Linux okdev1383 3.11.0-15-generic #23-Ubuntu SMP Mon Dec 9 18:17:04 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 4.2
Patch Level: 45
Release Status: release

Description:
        The bash man page offers two options for the PS1 prompt:  \h  and \H.  \h is suppose to be for the short form of the host name whereas \H can be the longer form.  The text reads:

\h
The hostname, up to the first ‘.’.

\H
The hostname.


The difference would imply that using \H would give you the FQDN version of the host name, but that is not the case.  It is distro specific.

See https://bugs.launchpad.net/ubuntu/+source/bash/+bug/1276796 for a
discussion thread on this issue in Ubuntu.


Repeat-By:
        Tested on Ubuntu 12.04 and 13.10.  Set PS1 with \H.  Because Ubuntu's installer creates /etc/hostname without the FQDN (as recommended in their man pages) bash never gets a host name other than the short version.

Fix:
        Option 1:  use a function other than gethostname when the \H option is supplied.  If the system doesn't have a FQDN this may not change anything, but it has a better chance at avoiding disto specific behavior.

        Option 2:  Update the documentation as follows:

\h
The hostname, up to the first '.'.

\H
The hostname.  May or may not include the domain name or FQDN.

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to bash in Ubuntu.
https://bugs.launchpad.net/bugs/1276796

Title:
  bash fails to provide FQDN for PS1 with \H

Status in “bash” package in Ubuntu:
  Invalid

Bug description:
  When using "\H" in the PS1 prompt value bash is not displaying the
  FQDN but instead only the short form hostname.  This is the same as
  "\h".

  Issue has also been noted at 
  http://serverfault.com/questions/296970/bash-prompt-on-ubuntu-fqdn-h-same-as-hostname-h
  https://answers.launchpad.net/ubuntu/+source/bash/+question/200900

  This appears related to /etc/hostname only having the host and not the
  FQDN.

  Bash should obtain the \H value from somewhere other than /etc/hostname.
  --- 
  ApportVersion: 2.12.5-0ubuntu2.2
  Architecture: amd64
  DistroRelease: Ubuntu 13.10
  InstallationDate: Installed on 2014-01-16 (20 days ago)
  InstallationMedia: Ubuntu-Server 13.10 "Saucy Salamander" - Release amd64 (20131016)
  MarkForUpload: True
  Package: bash 4.2-5ubuntu3
  PackageArchitecture: amd64
  ProcEnviron:
   TERM=xterm
   PATH=(custom, no user)
   XDG_RUNTIME_DIR=<set>
   LANG=en_US.UTF-8
   SHELL=/bin/bash
  ProcVersionSignature: Ubuntu 3.11.0-15.23-generic 3.11.10
  Tags:  saucy
  Uname: Linux 3.11.0-15-generic x86_64
  UpgradeStatus: No upgrade log present (probably fresh install)
  UserGroups: adm cdrom dip lpadmin plugdev sambashare sudo

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/bash/+bug/1276796/+subscriptions



More information about the foundations-bugs mailing list