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

Fix -v example #174

Merged
merged 1 commit into from
Jan 21, 2025
Merged

Fix -v example #174

merged 1 commit into from
Jan 21, 2025

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?

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: String expressions bash variable set
1 participant