Conversation
There was a problem hiding this comment.
Pull Request Overview
This pull request updates the shell’s behavior in POSIXly-correct mode by preventing certain internal variables from being made read-only. Key changes include introducing a helper function (can_make_readonly) to check allowed variables, updating the typeset built-in error handling, and revising documentation and tests accordingly.
Files not reviewed (7)
- NEWS: Language not supported
- NEWS.ja: Language not supported
- doc/_readonly.txt: Language not supported
- doc/ja/_readonly.txt: Language not supported
- doc/ja/posix.txt: Language not supported
- doc/posix.txt: Language not supported
- tests/readonly-y.tst: Language not supported
Comments suppressed due to low confidence (1)
variable.c:1760
- [nitpick] Consider enhancing the error message with additional context (e.g. indicating that the restriction is due to POSIXly-correct mode) to improve user feedback.
xerror(0, Ngt("$%ls cannot be read-only"), arg);
POSIX.1-2024 XBD 8.1 clarifies the allowed behavior of the shell when the following variables are made read-only: - LINENO - OLDPWD - OPTARG - OPTIND - PWD 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.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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:
readonlybuilt-in to disallow making the variables$LINENO,$OLDPWD,$OPTARG,$OPTIND, and$PWDread-only in POSIXly-correct mode. [1] [2]Documentation updates:
doc/_readonly.txtanddoc/posix.txtto reflect the restriction on making specific variables read-only in POSIXly-correct mode. [1] [2]doc/ja/_readonly.txtanddoc/ja/posix.txt, with the same information. [1] [2]Test additions:
tests/readonly-y.tstto verify that attempting to make the restricted variables read-only results in appropriate error messages.Codebase enhancements:
can_make_readonlyinvariable.cto determine if a variable can be made read-only based on the POSIXly-correct mode. [1] [2]News updates:
NEWSandNEWS.jafiles to document the new behavior of thereadonlybuilt-in in POSIXly-correct mode. [1] [2]