Conversation
In section XBD 8.1 of POSIX.1-2024, the expected behavior of the shell is defined for the case when the `readonly` built-in is executed on the `$PWD` or `$OLDPWD` variable. The standard allows us to choose from three options, and we make the `cd` (and `pushd`) built-ins fail with non-zero exit status in this case.
POSIX.1-2024 XBD 8.1 clarifies the allowed behavior of the shell when the OPTIND or OPTARG variable is made readonly. This commit adds tests to check the behavior.
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.
This pull request introduces changes to the behavior of the
cdbuilt-in command, updates related documentation, and adds new test cases to validate the changes. The updates ensure thatcdreturns an appropriate exit status when the$PWDor$OLDPWDvariables are read-only, aligning with POSIX standards.Behavior Changes:
cdbuilt-in to return exit status1if the$PWDor$OLDPWDvariables cannot be updated due to being read-only. Previously, this scenario did not affect the exit status. [1] [2] [3]Documentation Updates:
doc/_cd.txtto reflect the new behavior of thecdcommand when$PWDor$OLDPWDare read-only. Removed outdated notes indicating that this scenario does not affect the exit status. [1] [2]doc/ja/_cd.txtto align with the new behavior and clarify the exit status scenarios.Test Enhancements:
tests/cd-p.tstandtests/cd-y.tstto verify the behavior of thecdbuilt-in when$PWDor$OLDPWDare read-only. These tests ensure the exit status is correctly set to1in such cases. [1] [2] [3]tests/dirstack-y.tstto validate exit status1for scenarios involving read-only$PWDor$OLDPWD. [1] [2]These changes improve compliance with POSIX standards and enhance the robustness of the
cdcommand's behavior in edge cases.