mirror of
https://github.com/RustyRaptor/ProgrammingLanguages.git
synced 2026-12-04 05:55:15 -07:00
Added bash example
This commit is contained in:
1 parent
469d605100
commit
34a247d95e
1 file changed
+18
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Prints a string when we don't have short-circuit evaluation.
|
||||
function print_answer {
|
||||
echo "We DO NOT have short-circuit evaluation!"
|
||||
return 0
|
||||
}
|
||||
|
||||
# Set A to false to see if it skips or not.
|
||||
A=false
|
||||
|
||||
# If they are both true print that they are both true else print
|
||||
# A string we will use to see if we have short circuit eval.
|
||||
if [[ $A == true && $(print_answer) ]]; then
|
||||
echo "Both A and B are true"
|
||||
else
|
||||
echo "If you only see this then we DO have short circuit evaluation"
|
||||
fi
|
||||
Reference in new issue
Block a user