Details
-
Sub-task
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
HADOOP-12111
Description
Because $maxlen is not defined as a local variable, the preceding invocations effect the following results.
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}" }
Also,
until [[ ${i} -gt ${sizeofa} ]]; do
should be -eq or -ge.