Reject making LINENO, OLDPWD, OPTARG, OPTIND, and PWD readonly #170
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
POSIX.1-2024 XBD 8.1 clarifies the allowed behavior of the shell when the following variables are made read-only:
The readonly built-in now refuses to make the above variables read-only in the POSIXly-correct mode because it is the most restrictive behavior allowed by the standard.
Summary by Copilot
This pull request introduces changes to prevent specific variables from being made read-only in POSIXly-correct mode. The updates include modifications to documentation, tests, and the codebase to enforce this restriction and provide appropriate error handling.
Changes to functionality:
readonly
built-in to disallow making the variables$LINENO
,$OLDPWD
,$OPTARG
,$OPTIND
, and$PWD
read-only in POSIXly-correct mode. [1] [2]Documentation updates:
doc/_readonly.txt
anddoc/posix.txt
to reflect the restriction on making specific variables read-only in POSIXly-correct mode. [1] [2]doc/ja/_readonly.txt
anddoc/ja/posix.txt
, with the same information. [1] [2]Test additions:
tests/readonly-y.tst
to verify that attempting to make the restricted variables read-only results in appropriate error messages.Codebase enhancements:
can_make_readonly
invariable.c
to determine if a variable can be made read-only based on the POSIXly-correct mode. [1] [2]News updates:
NEWS
andNEWS.ja
files to document the new behavior of thereadonly
built-in in POSIXly-correct mode. [1] [2]