Skip to content

Refactor triangle example to follow Shell Style Guide - #97

Open
HemantAsur wants to merge 2 commits into
S-AI-Projects:mainfrom
HemantAsur:R05-T044
Open

HemantAsur wants to merge 2 commits into
S-AI-Projects:mainfrom
HemantAsur:R05-T044

Conversation

@HemantAsur

Copy link
Copy Markdown

Description

The triangle exercise's .meta/example.sh needed improvements to align with the Google Shell Style Guide and pass ShellCheck with all optional checks enabled. This PR refactors the existing script to improve readability, consistency, error handling, and maintainability.

Related Issue

Fixes #45

Type of Change

  • Code Quality
  • Refactoring
  • Shell Script Improvements

Changes Made

  • Refactored exercises/practice/triangle/.meta/example.sh to follow the required shell scripting style.
  • Quoted variable expansions to prevent unexpected word splitting and pathname expansion.
  • Added braces around variable references and used [[ ]] for Bash conditional expressions.
  • Introduced local variables to improve function scope and readability.
  • Added error handling for the bc command substitution.
  • Improved triangle validation logic and comparison conditions.
  • Organized argument validation and command execution inside a dedicated main function.
  • Documented the ShellCheck SC2310 suppression and its rationale.
  • Added the original ShellCheck findings and validation evidence in work/R05-T044/findings.md.

Testing

  • shellcheck -o all exercises/practice/triangle/.meta/example.sh — no diagnostics found.
  • bin/validate_one_exercise exercises/practice/triangle — all 21 tests passed.

Screenshots / Recordings

N/A (no UI changes).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hemant Gandhe — R05-T044: Bring 'triangle' example.sh up to the style guide

1 participant