From 9f219e746a1e3a1fd9d47dd908113d0d812885f9 Mon Sep 17 00:00:00 2001 From: macmarrum <7197131+macmarrum@users.noreply.github.com> Date: Sat, 9 Aug 2025 13:45:11 +0200 Subject: [PATCH 1/2] fix inaccurate description and change if-statement examples to match it Unlike `[ ... ]`, `[[ ... ]]` allows `&&` and `||` inside the brackets --- bash.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bash.md b/bash.md index 6ce1734ecf..cb78a583af 100644 --- a/bash.md +++ b/bash.md @@ -166,13 +166,13 @@ else echo "Your name is your username" fi -# To use && and || with if statements, you need multiple pairs of square brackets: +# You can use && and || with if statements: read age -if [[ "$name" == "Steve" ]] && [[ "$age" -eq 15 ]]; then +if [[ "$name" == "Steve" && "$age" -eq 15 ]]; then echo "This will run if $name is Steve AND $age is 15." fi -if [[ "$name" == "Daniya" ]] || [[ "$name" == "Zach" ]]; then +if [[ "$name" == "Daniya" || "$name" == "Zach" ]]; then echo "This will run if $name is Daniya OR Zach." fi From 2a5cbd033af929e64e2e3361ba18197c5ebd2190 Mon Sep 17 00:00:00 2001 From: macmarrum <7197131+macmarrum@users.noreply.github.com> Date: Sat, 9 Aug 2025 13:46:54 +0200 Subject: [PATCH 2/2] change to `[[ ... ]]` for consistency with other examples --- bash.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash.md b/bash.md index cb78a583af..4f6150321f 100644 --- a/bash.md +++ b/bash.md @@ -411,7 +411,7 @@ do done # while loop: -while [ true ] +while [[ true ]] do echo "loop body here..." break