bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

nullglob option breaks complex parameter expansion/deletion


From: michael
Subject: nullglob option breaks complex parameter expansion/deletion
Date: Fri, 1 Jul 2005 17:17:22 +1000 (EST)

Configuration Information [Automatically generated, do not change]:
Machine: i386
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i386' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i386-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   -g -O2
uname output: Linux eagle.endbracket.net 2.6.7eagle-20040916 #1 Thu Sep 16 
23:36:29 EST 2004 i686 GNU/Linux
Machine Type: i386-pc-linux-gnu

Bash Version: 3.0
Patch Level: 16
Release Status: release

Description:
        I had been using ${HOSTNAME%%.*} in my prompt to show the local
        host name portion of my full host name (e.g. localhost instead
        of localhost.localdomain).  After enabling the nullglob shell
        option, this pattern is being replaced by a null string.  I
        don't think this behavior is desireable.

        I don't fully understand the wording of the relevant portion of
        the POSIX standard on this topic, but I would expect this
        pattern to always function as it does without nullglob set:
        - the /word/ to delete is a shell glob pattern to apply to the
          result of expanding the /parameter/, regardless of whether the
          word matches any file names in the current directory
        - the deletion occurs regardless of whether the expansion of
          /parameter/ is a file name
        - the expansion of /parameter/ remains intact if the /word/ does
          not match any portion of /parameter/

        The standard also suggests that quoting /word/ shall cause it to
        be regarded as literal rather than a pattern, but quoting /word/
        exhibits the same problem.

Repeat-By:
        $ shopt -u nullglob
        $ connectioninfo='${HOST%%.*} ${USER}'
        $ echo $connectioninfo
        ${HOST%%.*} ${USER}
        $ shopt -s nullglob
        $ echo $connectioninfo
        ${USER}





reply via email to

[Prev in Thread] Current Thread [Next in Thread]