[Bug ld/6854] New: Use of BASH_LINENO[0] in ld/genscripts.sh prevents use of dash

View: New views
3 Messages — Rating Filter:   Alert me  

[Bug ld/6854] New: Use of BASH_LINENO[0] in ld/genscripts.sh prevents use of dash

by Bugzilla from sourceware-bugzilla@sourceware.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi!
  In building a complete cross-toolchain with CONFIG_SHELL=/bin/ash (-> dash) is
frustrated by a single line in ld/genscripts.sh:

...
if test -n "${BASH+set}"; then
  printenv | grep BASH
  source_em()
  {
    local current_script="$em_script"
    em_script=$1
    . $em_script
    em_script=$current_script
  }
  fragment()
  {
    local lineno=$[${BASH_LINENO[0]} + 1]   # <==== dash dies here
    echo >> e${EMULATION_NAME}.c "#line $lineno \"$em_script\""
    cat >> e${EMULATION_NAME}.c
  }
else
...

Although dash doesn't execute the BASH_ code, it still dies parsing it, saying:

binutils-2.18/ld/genscripts.sh: 403: Syntax error: Bad substitution

Using dash knocks 35% off the elapsed build time for the toolchain compared to
bash - is this line-number-reporting code really worth it?

One fix is to drop the complex "then" clause leaving the body of the simple
"else" clause.

Another, keeping the exact same line-number bash functionality in a
non-dash-poisonous way is to achieve the same effect, substituting for the
fragment() function the following code:

  alias fragment='em_lineno=$LINENO; fragment_em'
  fragment_em()
  {
    local lineno=$[$em_lineno + 1]
    echo >> e${EMULATION_NAME}.c "#line $lineno \"$em_script\""
    cat >> e${EMULATION_NAME}.c
  }

I've tested this; with bash the files generated by genscripts.sh are identical
to those made with the original version, while using CONFIG_SHELL=/bin/dash the
binutils build finishes in

--
           Summary: Use of BASH_LINENO[0] in ld/genscripts.sh prevents use
                    of dash
           Product: binutils
           Version: 2.18
            Status: NEW
          Severity: minor
          Priority: P2
         Component: ld
        AssignedTo: unassigned at sources dot redhat dot com
        ReportedBy: martinwguy at yahoo dot it
                CC: bug-binutils at gnu dot org


http://sourceware.org/bugzilla/show_bug.cgi?id=6854

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


_______________________________________________
bug-binutils mailing list
bug-binutils@...
http://lists.gnu.org/mailman/listinfo/bug-binutils

[Bug ld/6854] Use of BASH_LINENO[0] in ld/genscripts.sh prevents use of dash

by Bugzilla from sourceware-bugzilla@sourceware.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


------- Additional Comments From martinwguy at yahoo dot it  2008-08-25 16:06 -------
Created an attachment (id=2928)
 --> (http://sourceware.org/bugzilla/attachment.cgi?id=2928&action=view)
Patch to enable use of CONFIG_SHELL=/bin/dash


--


http://sourceware.org/bugzilla/show_bug.cgi?id=6854

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


_______________________________________________
bug-binutils mailing list
bug-binutils@...
http://lists.gnu.org/mailman/listinfo/bug-binutils

[Bug ld/6854] Use of BASH_LINENO[0] in ld/genscripts.sh prevents use of dash

by Bugzilla from sourceware-bugzilla@sourceware.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


------- Additional Comments From amodra at bigpond dot net dot au  2008-08-25 23:11 -------
Already fixed in mainline CVS.

--
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


http://sourceware.org/bugzilla/show_bug.cgi?id=6854

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


_______________________________________________
bug-binutils mailing list
bug-binutils@...
http://lists.gnu.org/mailman/listinfo/bug-binutils
LightInTheBox - Buy quality products at wholesale price!