Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Readonly builtin #320

Merged
merged 11 commits into from
Nov 23, 2023
Merged

Readonly builtin #320

merged 11 commits into from
Nov 23, 2023

Conversation

magicant
Copy link
Owner

@magicant magicant commented Nov 23, 2023

Summary by CodeRabbit

  • New Features

    • Enhanced the export and readonly built-in commands with clarified behavior and additional documentation.
    • Improved the typeset built-in to print variables and functions in alphabetical order and handle array variables more effectively.
  • Documentation

    • Added detailed documentation for readonly built-in covering behavior, options, operands, and standard output.
  • Refactor

    • Renamed PRINT_VARIABLES_CONTEXT to PRINT_CONTEXT across various modules for consistency.
    • Updated typeset built-in implementation to support different behaviors and introduced PrintContext for command details.
  • Tests

    • Added new test cases for readonly and typeset built-ins to ensure compliance with POSIX standards.
    • Introduced readonly-p.sh and updated typeset-y.sh test scripts for comprehensive testing of shell built-ins.
  • Bug Fixes

    • Fixed issues related to the readonly built-in to prevent re-assignment of read-only variables.

It is found that PrintVariablesContext can be used to print not only
variables but also functions. This commit renames it to PrintContext to
reflect the fact.
A reference to an object with a static lifetime should be const.
If it is declared static, not only the referenced object but also the
reference itself will occupy a memory for a static lifetime.
This commit introduces a new field `builtin_is_significant` to the
`PrintContext` struct. When this field is true, the command that invokes
the built-in is always printed regardless of the attributes of the
variables or functions. This field is true for the export and readonly
built-ins, but false for the typeset built-in.
@magicant magicant added the enhancement New feature or request label Nov 23, 2023
Copy link

coderabbitai bot commented Nov 23, 2023

The existing content is still valid, so I will repeat it verbatim:

Walkthrough

The updates across various shell built-in commands (export, readonly, typeset) involve enhanced documentation, refactoring, and improved functionality. The changes clarify command behaviors, standardize output, and introduce a new PrintContext structure for consistent handling of printing variables and functions. Code refactoring includes renaming variables for clarity and removing unnecessary wrapping in closures. Tests have been added or adjusted to align with the updated built-ins.

Changes

File Path Change Summary
yash-builtin/src/export.rs
yash-builtin/src/readonly.rs
yash-builtin/src/typeset.rs
Updated documentation, added PrintContext, refactored code, and clarified standard output behavior.
yash-builtin/src/lib.rs Simplified the execute field for the "readonly" command by removing unnecessary wrapping.
yash-builtin/src/typeset/print_...rs Added PrintContext parameter to function signatures and updated tests.
yash/tests/scripted_test.rs Added a new test function readonly_builtin.
yash/tests/scripted_test/readonly-p.sh
yash/tests/scripted_test/typeset-y.sh
Modified test scripts to reflect changes in built-in commands and removed outdated TODOs.

As autumn leaves 🍂 gently fall,
CodeRabbit 🐇 hops through the code,
Refactoring and testing with glee,
For a shell that's polished and free! 🌟


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between c087fb1 and 4bdaea2.
Files selected for processing (8)
  • yash-builtin/src/export.rs (5 hunks)
  • yash-builtin/src/lib.rs (1 hunks)
  • yash-builtin/src/readonly.rs (2 hunks)
  • yash-builtin/src/typeset.rs (10 hunks)
  • yash-builtin/src/typeset/print_functions.rs (12 hunks)
  • yash-builtin/src/typeset/print_variables.rs (27 hunks)
  • yash/tests/scripted_test.rs (1 hunks)
  • yash/tests/scripted_test/readonly-p.sh (1 hunks)
Files skipped from review due to trivial changes (1)
  • yash/tests/scripted_test.rs
Additional comments: 53
yash-builtin/src/lib.rs (1)
  • 144-148:
    Ensure that the readonly::main function is now properly returning a Future and that this change is compatible with the rest of the codebase where readonly::main is expected to be called.
yash/tests/scripted_test/readonly-p.sh (3)
  • 5-11:
    The test case for making a single variable read-only is well-defined and checks the expected behavior correctly.

  • 13-20:
    The test case for making multiple variables read-only is well-defined and checks the expected behavior correctly.

  • 26-32:
    The test case for ensuring a read-only variable cannot be reassigned is well-defined and includes an explanation for the expected behavior when the readonly built-in fails.

yash-builtin/src/readonly.rs (3)
  • 17-191: The documentation added for the readonly built-in is comprehensive and well-structured, providing clear information on its behavior, options, operands, and output. This will greatly enhance the maintainability and usability of the code.

  • 222-248: The main function has been refactored to be asynchronous and now properly handles the execution of the readonly built-in command. The use of parse and interpret functions from the typeset module, along with the new PRINT_CONTEXT constant, shows a good separation of concerns and code reuse.

  • 262-268: The test case builtin_defines_read_only_variable checks if the readonly built-in correctly defines a read-only variable. However, the test case seems to be missing an assertion to check if the variable is indeed set as read-only. This should be verified and potentially corrected to ensure the test case is comprehensive.

yash-builtin/src/export.rs (5)
  • 26-33: The updated description of the -p option in the export built-in command is clear and informative, explaining the behavior with and without operands.

  • 43-61: The clarification on operands and standard output behavior when exporting or printing variables is well-documented and improves the understanding of the command's functionality.

  • 80-87: The implementation notes provide valuable insight into the relationship between the export and typeset built-ins, which is useful for developers working with the codebase.

  • 95-113: The refactoring to rename PRINT_VARIABLES_CONTEXT to PRINT_CONTEXT and the associated updates to structures and functions align with the changes mentioned in the summary and improve code consistency.

  • 129-134: The use of unreachable! macro for Command::SetFunctions and Command::PrintFunctions variants ensures that the export built-in does not handle function-related commands, which is consistent with its intended behavior.

yash-builtin/src/typeset.rs (5)
  • 82-86: The documentation mentions that variables are printed in alphabetical order, but there is no code in the provided hunks that shows the implementation of this sorting. Verify that the sorting logic is implemented elsewhere in the codebase.

  • 126-131: The documentation explains the special handling of array variables when printing, including the omission of the typeset command if no options are applied. Ensure that the implementation of this behavior is consistent with the documentation.

  • 177-181: The documentation states that shell functions are printed in alphabetical order. Similar to the sorting of variables, verify that the sorting logic for functions is implemented elsewhere in the codebase.

  • 263-270: The documentation has been updated to reflect the parameterization of common functions to support different behaviors of the built-ins. Ensure that the refactoring has been done correctly and that the parameterization does not introduce any regressions or unexpected behaviors.

  • 482-493: The execute method is responsible for executing the command and returning the result or errors. Ensure that the error handling and result output are consistent with the new asynchronous error reporting and result output functions mentioned in the pull request summary.

yash-builtin/src/typeset/print_functions.rs (12)
  • 22-30: The execute method in the PrintFunctions struct has been updated to include a new context parameter of type &PrintContext. This change aligns with the summary indicating that the print_one function now uses the context parameter to determine options for printing and the significance of the built-in name. The method signature change is consistent with the described enhancements.

  • 34-45: The sorting of functions is done using an unstable sort, which is fine for sorting by function names as they are expected to be unique. However, the comment on line 34 indicates a TODO for honoring the collation order in the locale, which is not addressed in this change. This is consistent with the learning that locale-specific sorting is recognized as a potential enhancement but not implemented due to extensive changes required across the codebase.

  • 67-98: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [56-96]

The print_one function has been updated to include the context parameter and uses it to determine which options to print and whether the built-in name is significant. This change is in line with the summary of changes and the new tests added to cover different scenarios using the PrintContext struct. The implementation appears to be correct and matches the intended functionality.

  • 123-127: The test printing_one_function checks the output of the execute method for a single function. The test is straightforward and correctly asserts the expected output. The use of PRINT_CONTEXT is consistent with the changes made to the PrintFunctions struct.

  • 147-152: The test printing_multiple_functions checks the output of the execute method for multiple functions. The test is well-structured and correctly asserts the expected output. The use of PRINT_CONTEXT is consistent with the changes made to the PrintFunctions struct.

  • 173-178: The test printing_all_functions checks the output of the execute method when all functions are to be printed. The test correctly asserts that the output is sorted by function name, which is consistent with the implementation in the execute method.

  • 192-197: The test quoting_function_name checks the output of the execute method for a function with a name that requires quoting. The test correctly asserts the expected output, including the use of the function keyword and quoting of the function name.

  • 211-215: The test printing_readonly_functions checks the output of the execute method for a read-only function. The test correctly asserts the expected output, including the command to set the function attributes. The use of PRINT_CONTEXT is consistent with the changes made to the PrintFunctions struct.

  • 236-241: The test selecting_readonly_functions checks the output of the execute method when filtering for read-only functions. The test correctly asserts the expected output, including the command to set the function attributes. The use of PRINT_CONTEXT is consistent with the changes made to the PrintFunctions struct.

  • 261-265: The test selecting_non_readonly_functions checks the output of the execute method when filtering for non-read-only functions. The test correctly asserts the expected output, which should only include the non-read-only function.

  • 275-283: The test function_not_found checks the error handling of the execute method when the specified functions are not found in the FunctionSet. The test correctly asserts the expected errors, which are instances of ExecuteError::PrintUnsetFunction.

  • 287-393: The tests in the non_default_context module verify the behavior of the execute method with different PrintContext configurations. The tests correctly assert the expected outputs based on the context settings, such as the significance of the built-in name and the allowed options. These tests are important to ensure that the PrintContext struct is being used correctly within the PrintFunctions struct.

yash-builtin/src/typeset/print_variables.rs (24)
  • 23-29: The execute function in PrintVariables returns a Result<String, Vec<ExecuteError>>, which is good for error handling. However, it's important to ensure that all callers of this function are updated to handle the new return type if this is a change from the previous implementation.

  • 57-63: The print_one function has been updated to use the new PrintContext. Ensure that all calls to this function have been updated to pass the new PrintContext instead of the previous PrintVariablesContext.

  • 89-95: The logic for printing array variables has been updated to consider builtin_is_significant. Ensure that the new behavior is consistent with the expected output format for array variables in all use cases.

  • 151-157: The test printing_one_variable uses a hardcoded PRINT_CONTEXT. If PRINT_CONTEXT has been updated or replaced in the codebase, this test should be updated to reflect those changes.

  • 174-180: Similar to the previous comment, the test printing_multiple_variables should be verified to use the correct context if there have been changes to PRINT_CONTEXT.

  • 193-198: The test printing_array_variable should be verified for the correct usage of PRINT_CONTEXT, especially since array printing logic has been updated in the main code.

  • 207-212: The test printing_valueless_variable should be verified for the correct usage of PRINT_CONTEXT.

  • 228-234: The test quoting_variable_names_and_values should be verified for the correct usage of PRINT_CONTEXT.

  • 254-260: The test printing_global_and_local_variables_at_once should be verified for the correct usage of PRINT_CONTEXT.

  • 278-284: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [278-292]

The tests printing_local_variables_only and the following test for printing a variable that is not found in the local scope should be verified for the correct usage of PRINT_CONTEXT.

  • 315-321: The test printing_all_global_and_local_variables should be verified for the correct usage of PRINT_CONTEXT.

  • 346-352: The test printing_all_local_variables should be verified for the correct usage of PRINT_CONTEXT.

  • 370-376: The test printing_attributes_of_valueless_variables should be verified for the correct usage of PRINT_CONTEXT.

  • 397-403: The test printing_attributes_of_scalar_variables should be verified for the correct usage of PRINT_CONTEXT.

  • 424-430: The test printing_attributes_of_array_variables should be verified for the correct usage of PRINT_CONTEXT.

  • 457-462: The test selecting_readonly_variables should be verified for the correct usage of PRINT_CONTEXT.

  • 473-478: The test selecting_non_readedonly_variables should be verified for the correct usage of PRINT_CONTEXT.

  • 489-494: The test selecting_exported_variables should be verified for the correct usage of PRINT_CONTEXT.

  • 505-510: The test selecting_non_exported_variables should be verified for the correct usage of PRINT_CONTEXT.

  • 520-524: The test selecting_with_multiple_filtering_attributes should be verified for the correct usage of PRINT_CONTEXT.

  • 534-541: The test variable_not_found should be verified for the correct usage of PRINT_CONTEXT.

  • 562-570: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [562-577]

The test builtin_name in the non_default_context module should be verified for the correct usage of PRINT_CONTEXT and to ensure that the new builtin_name field is being used correctly.

  • 581-607: The tests builtin_is_significant and insignificant_builtin_with_attributed_array should be verified for the correct usage of PRINT_CONTEXT and to ensure that the new builtin_is_significant field is being used correctly.

  • 650-658: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [650-682]

The tests in the options_allowed section should be verified for the correct usage of PRINT_CONTEXT and to ensure that the new options_allowed field is being used correctly.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 4bdaea2 and 16929dc.
Files selected for processing (1)
  • yash/tests/scripted_test/typeset-y.sh (2 hunks)
Files skipped from review due to trivial changes (1)
  • yash/tests/scripted_test/typeset-y.sh

@magicant magicant self-assigned this Nov 23, 2023
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 4

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between c087fb1 and 8a2d50a.
Files selected for processing (9)
  • yash-builtin/src/export.rs (5 hunks)
  • yash-builtin/src/lib.rs (1 hunks)
  • yash-builtin/src/readonly.rs (2 hunks)
  • yash-builtin/src/typeset.rs (10 hunks)
  • yash-builtin/src/typeset/print_functions.rs (12 hunks)
  • yash-builtin/src/typeset/print_variables.rs (27 hunks)
  • yash/tests/scripted_test.rs (1 hunks)
  • yash/tests/scripted_test/readonly-p.sh (1 hunks)
  • yash/tests/scripted_test/typeset-y.sh (2 hunks)
Files skipped from review due to trivial changes (3)
  • yash-builtin/src/lib.rs
  • yash/tests/scripted_test.rs
  • yash/tests/scripted_test/typeset-y.sh
Additional comments: 55
yash-builtin/src/readonly.rs (5)
  • 60-60: The TODO comment about linking to the eval built-in should be addressed if the documentation is ready to be linked.

  • 129-129: Similar to the previous comment, the TODO about linking to the eval built-in should be addressed if the documentation is ready to be linked.

  • 220-220: The TODO comment about splitting into syntax and semantics submodules should be removed if this refactoring has been completed, or it should be updated to reflect the current state of the codebase.

  • 223-248: The main function has been correctly updated to be asynchronous and return a Result wrapped in a future. The use of parse, interpret, and execute functions for handling options, operands, and command execution is a good refactor for maintainability and readability.

  • 262-268: The test case builtin_defines_read_only_variable has been updated to reflect the new asynchronous nature of the main function. The use of now_or_never() from futures_util to immediately resolve the future is appropriate for testing.

yash-builtin/src/export.rs (5)
  • 26-33: The updated documentation clearly explains the behavior of the export built-in with and without the -p option. This aligns with the summary of changes indicating clarification in the documentation.

  • 43-61: The documentation now includes a description of the operands and the standard output behavior, which is consistent with the summary of changes. It is important to ensure that the behavior described here matches the actual implementation in the code.

  • 80-87: The implementation notes have been updated to reflect the relationship between the export and typeset built-ins. This should be verified to ensure that the behavior described is consistent with the actual code.

  • 95-113: The PRINT_VARIABLES_CONTEXT has been renamed to PRINT_CONTEXT and its type updated to PrintContext, as mentioned in the summary. This change should be cross-checked with other parts of the codebase to ensure consistency.

  • 129-134: The main function now handles the Command::SetFunctions and Command::PrintFunctions cases with unreachable! macros, which is a good way to assert conditions that are expected to never happen. However, it is crucial to ensure that these cases are indeed not possible in the current context of the export built-in.

yash-builtin/src/typeset.rs (9)
  • 82-86: The TODO comment about linking to the eval built-in should be addressed or removed if it is no longer relevant.

  • 163-167: The note about the built-in operating on existing shell functions only is important. It should be made clear in the documentation that this built-in cannot be used to create new functions or modify the body of existing functions.

  • 227-234: The error conditions are well documented, which is good for maintainability and understanding the limitations of the built-in's functionality.

  • 263-270: The explanation of how the implementation of the typeset built-in is shared with the export and readonly built-ins is clear and provides good insight into the code's modularity.

  • 354-355: The Scope enum is well-defined, making it clear how the scope of operations is determined for printing variables.

  • 393-394: The PrintFunctions struct is well-defined, making it clear how the attributes for printing functions are determined.

  • 402-428: The PrintContext struct is a good addition for controlling the details of the commands when printing variables or functions. It allows for flexibility and reusability of the printing logic.

  • 482-493: The execute method is well-structured and handles the different command types effectively. It's good to see that it returns a Result type, which is idiomatic Rust for error handling.

  • 646-652: The main function is now async and properly handles the execution of the typeset built-in, including error reporting. This aligns with the asynchronous nature of the shell environment.

yash-builtin/src/typeset/print_functions.rs (13)
  • 22-30: The execute method in the PrintFunctions struct has been updated to take a context parameter of type &PrintContext. This change aligns with the overall refactoring effort to parameterize the implementation and control the details of the commands using the PrintContext struct.

  • 34-35: The comment indicates a TODO for honoring the collation order in the locale. This is a known enhancement that has not been implemented due to the extensive changes required across the codebase. It's important to track this as a potential future improvement.

  • 56-60: The print_one function now takes an extra parameter context of type &PrintContext. This change is part of the refactoring to pass additional context information to the printing functions.

  • 67-96: The print_one function has been updated to include logic for printing function attributes based on the PrintContext. This includes handling the builtin_is_significant flag and printing options allowed by the context. This change enhances the flexibility and configurability of the printing behavior.

  • 123-127: A test case has been added to verify the printing of a single function. This test ensures that the execute method correctly prints the function body when provided with a specific function name.

  • 147-152: Another test case has been added to verify the printing of multiple functions. This test checks that the execute method correctly prints the bodies of multiple functions in the order they are provided.

  • 173-178: This test case verifies that all functions are printed and that the result is sorted by function name. This aligns with the new behavior of printing shell variables and functions in alphabetical order.

  • 192-197: The test case for quoting function names ensures that function names that require quoting are correctly prefixed with the function keyword and quoted in the output.

  • 211-216: The test case for printing read-only functions checks that the execute method correctly prints the function body and the command to set the function as read-only.

  • 236-241: This test case verifies the selection and printing of read-only functions, ensuring that the execute method correctly filters and prints functions based on their attributes.

  • 261-266: The test case for selecting non-read-only functions ensures that the execute method correctly filters out read-only functions when the attribute filter specifies non-read-only functions.

  • 275-284: The test case for handling functions not found in the FunctionSet checks that the execute method correctly returns errors for each function that does not exist.

  • 290-393: A series of test cases have been added under the non_default_context module to cover different scenarios using the PrintContext struct. These tests verify the behavior of the execute method when the builtin_name, builtin_is_significant, and options_allowed fields of the PrintContext are varied.

yash-builtin/src/typeset/print_variables.rs (23)
  • 23-29: The execute method has been updated to use the new PrintContext type. However, the method signature change from PrintVariablesContext to PrintContext may affect other parts of the code that rely on this method. Ensure that all calls to execute have been updated accordingly.

  • 57-63: The print_one function has been updated to use the new PrintContext type. This change is consistent with the refactoring mentioned in the summary. Ensure that all calls to print_one have been updated to pass the new PrintContext type.

  • 89-95: The logic for printing array variables has been updated to include a check for builtin_is_significant. This is a new field in the PrintContext struct and affects the output format. Ensure that the new behavior is intended and correctly implemented across all use cases.

  • 151-157: The test case printing_one_variable has been updated to use the new PrintContext instead of the old PRINT_VARIABLES_CONTEXT. This change is consistent with the refactoring mentioned in the summary. Ensure that the test case still passes with the new context.

  • 174-180: The test case printing_multiple_variables has been updated to use the new PrintContext. Ensure that the test case still passes with the new context and that the output format is as expected.

  • 193-198: The test case printing_array_variable has been updated to use the new PrintContext. Ensure that the test case still passes with the new context and that the output format is as expected.

  • 207-212: The test case printing_valueless_variable has been updated to use the new PrintContext. Ensure that the test case still passes with the new context and that the output format is as expected.

  • 228-234: The test case quoting_variable_names_and_values has been updated to use the new PrintContext. Ensure that the test case still passes with the new context and that the output format is as expected.

  • 254-260: The test case printing_global_and_local_variables_at_once has been updated to use the new PrintContext. Ensure that the test case still passes with the new context and that the output format is as expected.

  • 278-284: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [278-293]

The test cases for printing local variables only and attempting to print a global variable in the local scope have been updated to use the new PrintContext. Ensure that the test cases still pass with the new context and that the output format is as expected, including the error case.

  • 315-321: The test case printing_all_global_and_local_variables has been updated to use the new PrintContext. Ensure that the test case still passes with the new context and that the output format is as expected.

  • 346-352: The test case printing_all_local_variables has been updated to use the new PrintContext. Ensure that the test case still passes with the new context and that the output format is as expected.

  • 370-376: The test case printing_attributes_of_valueless_variables has been updated to use the new PrintContext. Ensure that the test case still passes with the new context and that the output format is as expected.

  • 397-403: The test case printing_attributes_of_scalar_variables has been updated to use the new PrintContext. Ensure that the test case still passes with the new context and that the output format is as expected.

  • 424-430: The test case printing_attributes_of_array_variables has been updated to use the new PrintContext. Ensure that the test case still passes with the new context and that the output format is as expected.

  • 457-462: The test case selecting_readonly_variables has been updated to use the new PrintContext. Ensure that the test case still passes with the new context and that the output format is as expected.

  • 473-478: The test case selecting_non_readonly_variables has been updated to use the new PrintContext. Ensure that the test case still passes with the new context and that the output format is as expected.

  • 489-494: The test case selecting_exported_variables has been updated to use the new PrintContext. Ensure that the test case still passes with the new context and that the output format is as expected.

  • 505-510: The test case selecting_non_exported_variables has been updated to use the new PrintContext. Ensure that the test case still passes with the new context and that the output format is as expected.

  • 520-524: The test case selecting_with_multiple_filtering_attributes has been updated to use the new PrintContext. Ensure that the test case still passes with the new context and that the output format is as expected.

  • 534-541: The test case variable_not_found has been updated to use the new PrintContext. Ensure that the test case still passes with the new context and that the error handling is correct.

  • 562-570: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [562-577]

The test cases in the non_default_context module have been updated to use the new PrintContext. Ensure that the test cases still pass with the new context and that the output format is as expected, including the handling of the builtin_name and builtin_is_significant fields.

  • 650-658: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [650-682]

The test cases for options_allowed have been updated to use the new PrintContext. Ensure that the test cases still pass with the new context and that the output format is as expected, including the handling of different option specifications.

yash/tests/scripted_test/readonly-p.sh Outdated Show resolved Hide resolved
yash-builtin/src/readonly.rs Show resolved Hide resolved
yash-builtin/src/typeset.rs Show resolved Hide resolved
The previous tests contained redundant commands that were not run as a
consequence of the preceding assignment failing. This patch removes
those redundant commands and adds comments to explain the expected
behavior.
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 8a2d50a and a0bed0f.
Files selected for processing (2)
  • yash-builtin/src/typeset.rs (10 hunks)
  • yash/tests/scripted_test/readonly-p.sh (1 hunks)
Additional comments: 8
yash-builtin/src/typeset.rs (8)
  • 82-86: The TODO comment about linking to the eval built-in should be addressed or removed if it is no longer relevant.

  • 124-145: The explanation and example provided for the standard output when printing variables, especially array variables, is clear and informative. This aligns with the previous learning about adding an example of the output format for clarity.

  • 174-175: The clarification that it is an error to modify a non-existing function is important for preventing undefined behavior and should be clearly documented.

  • 236-242: The error conditions are well documented, which is crucial for users to understand the limitations and expected behavior of the built-in commands.

  • 270-278: The modification of the implementation notes to indicate that the implementation of the typeset built-in is also used by the export and readonly built-ins is a good practice for maintainability and understanding of the codebase.

  • 363-368: The Scope enum is well-defined, providing clarity on the behavior of the typeset built-in in different contexts.

  • 402-407: The PrintFunctions struct is well-defined, providing clarity on the behavior of the typeset built-in when printing functions.

  • 491-503: The execute function is well-implemented, handling different commands appropriately and returning a Result type which is a good practice for error handling.

yash/tests/scripted_test/readonly-p.sh Show resolved Hide resolved
@magicant magicant merged commit aca34a3 into master Nov 23, 2023
@magicant magicant deleted the readonly-builtin branch November 23, 2023 12:55
@magicant magicant added this to the POSIX 2018 scripting milestone Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant