-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
The bugfix for BUG_CMDSPASGN backported in commit fae8862 caused two regressions with the += operator: 1. The += operator did not append to variables. Reproducer: $ integer foo=3 $ foo+=2 command eval 'echo $foo' 2 2. The += operator ignored the readonly attribute, modifying readonly variables in the same manner as above. Reproducer $ readonly bar=str $ bar+=ing command eval 'echo $bar' ing Both of the regressions above were caused by nv_putval() failing to clone the variable from the previous scope into the invocation-local scope. As a result, 'foo+=2' was effectively 0 + 2 (since ksh didn't clone 3). The first regression was noticed during the development of ksh93v-, so to fix both bugs I've backported the bugfix for the regression from the ksh93v- 2013-10-10 alpha version: https://www.mail-archive.com/ast-users@lists.research.att.com/msg00369.html src/cmd/ksh93/sh/name.c: - To fix both of the bugs above, find the variable to modify with nv_search(), then clone it into the invocation local scope. To fix the readonly bug as well, this is done before the NV_RDONLY check (otherwise np will be missing that attribute and be incorrectly modified in the invocation-local scope). - Update a nearby comment describing what sh_assignok() does (per this comment: #249 (comment)) src/cmd/ksh93/tests/builtins.sh: - Add regression tests for both of the now fixed regressions, loosely based on the regression tests in ksh93v-.
- Loading branch information
Showing
4 changed files
with
53 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters