Saw this script and I am trying to figure out what language is used... it's almost like C but I noticed the fi as a way to close the nested if.
function prompt () {
if [ "$noprompt" ] && [ "$#" = "1" ]; then
if [ "$1" = "yes" ]; then
echo "DEFAULT: yes"
return 0
else
echo "DEFAULT: no"
return 1
fi
fi
while true; do
echo "Enter \"yes\" or \"no\": "
read response
case $response
in
Y*) return 0 ;;
y*) return 0 ;;
N*) return 1 ;;
n*) return 1 ;;
*)
esac
done
}
fi are used by Unix/Linux shells in shell programming, This is an if statement.
fi statement is the fundamental control statement that allows Shell to make decisions and execute statements conditionally.
The fi is to close the if-block in the y) case statement and the ;; is used to end the y) case.
fi fi. If statement and else statement could be nested in bash. The keyword “fi” indicates the end of the inner if statement and all if statement should end with the keyword “fi”.
The piece of code is Unix shell. But the answer to the question
what language uses “fi”
is a bit longer. The usage of mirrored words, like if
and fi
or case
and esac
comes from Algol, for a nice summary see comparison of languages. It was Stephen Bourne who carried this from Algol to the Unix shell, he worked first on Algol, later on sh
and adb
of the early Unix systems. He favored this syntax so much that even the C
code he wrote for sh
and adb
looks like Algol thanks to a bunch of preprocessor macros. The curious can have a look at the 2.11BSD source code of source code of sh or adb. It compiles as C after all. So even in C one can find FI
when going back a long way in history.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With