Skip to content

Treatment of variables that should not be made readonly#169

Merged
magicant merged 2 commits into
trunkfrom
readonly
May 11, 2025
Merged

Treatment of variables that should not be made readonly#169
magicant merged 2 commits into
trunkfrom
readonly

Conversation

@magicant

@magicant magicant commented May 10, 2025

Copy link
Copy Markdown
Owner

This pull request introduces changes to the behavior of the cd built-in command, updates related documentation, and adds new test cases to validate the changes. The updates ensure that cd returns an appropriate exit status when the $PWD or $OLDPWD variables are read-only, aligning with POSIX standards.

Behavior Changes:

  • Updated the cd built-in to return exit status 1 if the $PWD or $OLDPWD variables cannot be updated due to being read-only. Previously, this scenario did not affect the exit status. [1] [2] [3]

Documentation Updates:

  • Revised English documentation in doc/_cd.txt to reflect the new behavior of the cd command when $PWD or $OLDPWD are read-only. Removed outdated notes indicating that this scenario does not affect the exit status. [1] [2]
  • Updated Japanese documentation in doc/ja/_cd.txt to align with the new behavior and clarify the exit status scenarios.

Test Enhancements:

  • Added new test cases in tests/cd-p.tst and tests/cd-y.tst to verify the behavior of the cd built-in when $PWD or $OLDPWD are read-only. These tests ensure the exit status is correctly set to 1 in such cases. [1] [2] [3]
  • Modified existing tests in tests/dirstack-y.tst to validate exit status 1 for scenarios involving read-only $PWD or $OLDPWD. [1] [2]

These changes improve compliance with POSIX standards and enhance the robustness of the cd command's behavior in edge cases.

@magicant magicant added this to the 2.59 milestone May 10, 2025
@magicant magicant self-assigned this May 10, 2025
magicant added 2 commits May 11, 2025 12:41
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.
@magicant
magicant marked this pull request as ready for review May 11, 2025 05:02
@magicant magicant added the bug Something isn't working label May 11, 2025
@magicant magicant mentioned this pull request May 10, 2025
56 tasks
@magicant
magicant merged commit 8dd2fe2 into trunk May 11, 2025
@magicant
magicant deleted the readonly branch May 11, 2025 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant