Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix spurious syntax error when using ${foo[${bar}..${baz}]} #436

Merged
merged 1 commit into from
Jan 27, 2022

Conversation

JohnoKing
Copy link

Attempting to use array subscript expansion with variables that aren't set currently causes a spurious syntax error (in ksh93u+ and older commits the reproducer crashes):

$ ksh -c 'echo ${foo[${bar}..${baz}]}'  # Shouldn't print anything
ksh: : arithmetic syntax error

src/cmd/ksh93/sh/macro.c:
- Backport a parser bugfix from ksh93v- 2012-08-24 that avoids setting mp->dotdot until the copyto() function's loop is finished.

src/cmd/ksh93/tests/arrays.sh:
- Add regression tests for this bug.

Attempting to use array subscript expansion with variables that aren't set
currently causes a spurious syntax error (in ksh93u+ and older commits the
reproducer crashes):
   $ ksh -c 'echo ${foo[${bar}..${baz}]}'  # Shouldn't print anything
   ksh: : arithmetic syntax error

src/cmd/ksh93/sh/macro.c:
- Backport a parser bugfix from ksh93v- 2012-08-24 that avoids setting
  mp->dotdot until the copyto() function's loop is finished.

src/cmd/ksh93/tests/arrays.sh:
- Add regression tests for this bug.
@McDutchie McDutchie merged commit 632214c into ksh93:dev Jan 27, 2022
@JohnoKing JohnoKing deleted the fix-dotdot branch January 27, 2022 13:01
McDutchie pushed a commit that referenced this pull request Jan 27, 2022
Attempting to use array subscript expansion with variables that
aren't set currently causes a spurious syntax error (in ksh93u+ and
older commits the reproducer crashes):
   $ ksh -c 'echo ${foo[${bar}..${baz}]}'  # Shouldn't print anything
   ksh: : arithmetic syntax error

src/cmd/ksh93/sh/macro.c:
- Backport a parser bugfix from ksh93v- 2012-08-24 that avoids
  setting mp->dotdot until the copyto() function's loop is
  finished.

src/cmd/ksh93/tests/arrays.sh:
- Add regression tests for this bug.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants