Skip to content
This repository was archived by the owner on Jun 16, 2025. It is now read-only.
This repository was archived by the owner on Jun 16, 2025. It is now read-only.

command -x fails to handle long arguments #1048

@siteshwar

Description

@siteshwar

Description of problem:
command -x fails to handle long arguments and crashes in _spawnveg() function.

Ksh version:
2017.0.0-devel-2089-ga16a0486

How reproducible:
Always

Steps to reproduce:

  1. Run below script from build directory:
# test command -x option
SHELL=src/cmd/ksh93/ksh

function longline
{
    integer i
    for((i=0; i < $1; i++))
    do
        print argument$i
    done
}

integer sum=0 n=100000
if ! ${SHELL:-ksh} -c 'print $#' count $(longline $n) > /dev/null  2>&1
then
    for i in $(command -p command -x ${SHELL:-ksh} -c 'print $#;[[ $1 != argument0 ]]' count $(longline $n) 2> /dev/null)
    do
        ((sum += $i))
   done

   (( sum == n )) || echo "command -x processed only $sum arguments"
   command -p command -x ${SHELL:-ksh} -c 'print $#;[[ $1 == argument0 ]]' count $(longline $n) > /dev/null  2>&1
   [[ $? != 1 ]] && echo 'incorrect exit status for command -x'
fi

Actual results:
ksh subprocesses crash while running this test.

Expected results:
ksh subprocesses should not crash.

Additional info:
I found this bug while trying to improve tests for command builtin. My changes can be seen in this branch.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions