You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-dev@hadoop.apache.org by "Kengo Seki (JIRA)" <ji...@apache.org> on 2015/07/08 08:59:04 UTC

[jira] [Created] (HADOOP-12206) The preceding invocations of findlargest in test-patch effect the following invocations result

Kengo Seki created HADOOP-12206:
-----------------------------------

             Summary: The preceding invocations of findlargest in test-patch effect the following invocations result
                 Key: HADOOP-12206
                 URL: https://issues.apache.org/jira/browse/HADOOP-12206
             Project: Hadoop Common
          Issue Type: Sub-task
          Components: yetus
            Reporter: Kengo Seki


Because $maxlen is not defined as a local variable, the preceding invocations effect the following results.

{code}
function findlargest
{
  local column=$1
  shift
  local a=("$@")
  local sizeofa=${#a[@]}
  local i=0

  until [[ ${i} -gt ${sizeofa} ]]; do
    # shellcheck disable=SC2086
    string=$( echo ${a[$i]} | cut -f$((column + 1)) -d\| )
    if [[ ${#string} -gt $maxlen ]]; then
      maxlen=${#string}
    fi
    i=$((i+1))
  done
  echo "${maxlen}"
}
{code}

Also, {code}until [[ ${i} -gt ${sizeofa} ]]; do{code} should be -eq or -ge.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)