Bug 504844

Summary: YaST2 bash autocompletion script error in posix mode (when POSIXLY_CORRECT is set)
Product: [openSUSE] openSUSE 11.1 Reporter: Michal Kubeček <mike>
Component: YaST2Assignee: Jiri Srain <jsrain>
Status: RESOLVED FIXED QA Contact: Jiri Srain <jsrain>
Severity: Minor    
Priority: P5 - None CC: mvidner
Version: Final   
Target Milestone: ---   
Hardware: All   
OS: openSUSE 11.1   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Michal Kubeček 2009-05-18 17:06:32 UTC
User-Agent:       Mozilla/5.0 (X11; U; Linux x86_64; cs-CZ; rv:1.9.0.10) Gecko/2009042700 SUSE/3.0.10-1.1.1 Firefox/3.0.10

If bash starts in interactive posix mode (i.e. with POSIXLY_CORRECT set), YaST2 autocompletion script shows an error on line 56 of /etc/bash_completion.d/yast2-completion.sh

The problem is the use of process substitution which is not available in posix mode.

Reproducible: Always

Steps to Reproduce:
1. export POSIXLY_CORRECT=1
2. bash

Actual Results:  
error message appears:

bash: /etc/bash_completion.d/yast2-completion.sh: line 56: syntax error near unexpected token `<'
bash: /etc/bash_completion.d/yast2-completion.sh: line 56: `                done < <(LC_ALL=C $YAST $mod $prev help 2>&1)'


Expected Results:  
no error
Comment 1 Arvin Schnell 2009-05-19 08:41:51 UTC
Jiri, the script is in yast2 base package.
Comment 2 Jiri Srain 2009-05-22 06:47:05 UTC
I'm aware of the bash completion script using a "bashism"; I already tried to get rid of it, but failed (I'm not bash geek enough)

If you could provide a patch, I will be happy to integrate it, but I was not able to fix it (I don't remember exactly, but I think that I even worked on it together with Martin). Hope you can understand it.
Comment 3 Martin Vidner 2009-05-22 08:56:48 UTC
What an opportunity to show off my bash-fu! :-)
The construct

  while read FOO; do
    ...
    LIST=("${LIST[@]}" "$ITEM")
  done < <(bar)

can be replaced by this, as long as ITEMs don't contain whitespace (which is true here):

  LIST=(` bar | while read FOO; do
    ...
    echo "$ITEM"
  done `)

BTW ($(foo)) cannot be used if foo contains ')' for 'case' statements, therefore (`foo`).

Fixed in SVN r57293, will be in yast2-2.18.16.