Negative LINENO possible with indirection

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

 



Hello,

While running the shunit2 test suite[1][2] against dash, the following
problem presented itself: when multiple layers of indirection are used,
$LINENO yields a negative number. It appears that the root of the
problem is that lineno is decremented in multiple places in src/eval.c
with no lower bound, but I wasn't sure how to fix that. A minimal test
case follows below.

Please CC me on replies - I'm not subscribed.

Max

[1] https://github.com/kward/shunit2/blob/master/shunit2_macros_test.sh
[2] https://code.foxkit.us/adelie/packages/blob/90520a71053e5b0d0e30fc641b38dddbafca8e76/user/shunit2/dash-negative-lineno.patch

#!/bin/dash
# Minimal reproducing case based on shunit2 test suite
# dash 0.5.10.2

macro1='eval function2 "${LINENO}"'

function2() {
  echo "Passed value of LINENO = $1"
}

function1() {
  ${macro1}
}

function1



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux