shift in for loop changes loop parameters

Bug #2002250 reported by Oğuz İsmail Uysal
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
mksh
Fix Committed
Undecided
Unassigned

Bug Description

This script

  set -- 1 2
  for x; do
    echo $x
    shift $#
  done

should print

  1
  2

according to POSIX. And it does so on every other shell except pdksh clones. On mksh the output is

  1
  mksh

which is wrong.

Revision history for this message
Thorsten Glaser (mirabilos) wrote :

Confirm-ish, but it DTRT if you write

    for x in "$@"; do

which the autoconf manual says to use anyway; however,

    for x
    do

doesn’t work, which is their second form.

This seems to be something inherited from pdksh. I’ll look into it.

Revision history for this message
Thorsten Glaser (mirabilos) wrote :

Committed revision 10063BB49DD394C7BF7.

Changed in mksh:
status: New → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.