Skip to content

Conversation

@bobbyiliev
Copy link
Owner

@bobbyiliev bobbyiliev commented Jan 21, 2025

What type of PR is this? (check all applicable)

  • ♻️ Refactor
  • ✨ Feature
  • 🐛 Bug Fix
  • 👷 Optimization
  • 📝 Documentation Update
  • 🚩 Other

Description

Repro:

#!/bin/bash VARNAME="Test" if [[ -v VARNAME ]]; then echo "Shell variable is set. Value: ${VARNAME}" else echo "Shell variable is not set" fi

Related Tickets & Documents

Fixes #173

Added to documentation?

  • 📜 readme
  • 🙅 no documentation needed

[optional] What gif best describes this PR or how it makes you feel?

@what-the-diff
Copy link

what-the-diff bot commented Jan 21, 2025

PR Summary

  • Enhanced Bash Conditional Expressions
    The update clarifies that the -v operator in Bash conditional expressions operates using the variable name directly, not the variable's value. This clears up any ambiguity for developers and improves the comprehensibility of the code.

  • Added Instructional Note
    A newly added note provides guidance that using ${varname} in these instances would yield false as opposed to carrying out the required evaluation. This guidance prevents potential code errors and fosters better coding practices.

@bobbyiliev bobbyiliev merged commit 1030de5 into main Jan 21, 2025
1 check passed
@bobbyiliev bobbyiliev deleted the fix-v-operator-example branch January 21, 2025 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant