<?xml version="1.0" encoding="UTF-8" ?>

<bugzilla version="5.2"
          urlbase="https://bugzilla.altlinux.org/"
          
          maintainer="jenya@basealt.ru"
>

    <bug>
          <bug_id>22022</bug_id>
          
          <creation_ts>2009-10-22 06:03:36 +0400</creation_ts>
          <short_desc>broken code in /etc/bash_completion: can&apos;t be sourced a second time</short_desc>
          <delta_ts>2017-07-24 12:14:23 +0300</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>3</classification_id>
          <classification>Distributions</classification>
          <product>Branch 5.0</product>
          <component>bash-completion</component>
          <version>unspecified</version>
          <rep_platform>all</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>minor</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Ivan Zakharyaschev">imz</reporter>
          <assigned_to name="murygin@altlinux.org">murygin</assigned_to>
          <cc>ildar</cc>
          
          <qa_contact name="qa-5.0@altlinux.org">qa-5.0</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>101954</commentid>
    <comment_count>0</comment_count>
    <who name="Ivan Zakharyaschev">imz</who>
    <bug_when>2009-10-22 06:03:36 +0400</bug_when>
    <thetext>bash-completion-20060301-alt06
bash-3.2.39-alt2

At the beginning of /etc/bash_completion, there is a code piece which is broken (doesn&apos;t meet its purpose):

# Alter the following to reflect the location of this file.
#
{
  # These declarations must go within braces in order to be able to silence
  # readonly variable errors.
  BASH_COMPLETION=&quot;${BASH_COMPLETION:-/etc/bash_completion}&quot;
  BASH_COMPLETION_DIR=&quot;${BASH_COMPLETION_DIR:=/etc/bash_completion.d}&quot;
} 2&gt;/dev/null || :
readonly BASH_COMPLETION BASH_COMPLETION_DIR

because if one sources it a second time, it actually bails out at this place rather than silently ignoring the errors from the reassignments of the &quot;readonlies&quot; as intended.

Illustration:

$ readonly x=1; { x=&quot;${x:-2}&quot;; } 2&gt; /dev/null || :; echo PASSED
$ 

If it worked as it was intended by the author, PASSED would be printed.

Probably, the solution would be to use the form &quot;${x:=2}&quot; instead of the present assignments:

$ readonly x=1; { : ${x:=2}; } 2&gt; /dev/null || :; echo &quot;PASSED with x holding &apos;$x&apos;.&quot;
bash: x: readonly variable
PASSED with x holding &apos;1&apos;.
$ 

Demonstration: Tracing what actually happens when sourcing the current variant for a second time:

[ivan@dell ~]$ set -x; . /etc/bash_completion
+ . /etc/bash_completion
++ &apos;[&apos; -n &apos;&apos; &apos;]&apos;
++ set +v
++ echo -ne &apos;\033]0;ivan@dell: /home/ivan\007&apos;
[ivan@dell ~]$ 


This error makes it inconvenient to test a new ~/.bash_profile like this:

$ . ~/.bash_profile

because this way it stops processing at /etc/bash_completion.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>164819</commentid>
    <comment_count>1</comment_count>
    <who name="ildar">ildar</who>
    <bug_when>2017-07-24 12:14:23 +0300</bug_when>
    <thetext>Похоже, починилось.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>