[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Meaning of fi at the end of commands if and while
From: |
G. Branden Robinson |
Subject: |
Re: Meaning of fi at the end of commands if and while |
Date: |
Sat, 28 Dec 2024 10:30:14 -0600 |
At 2024-12-28T16:28:17+0100, octavio carnero wrote:
> Good morning I,m a beginner with bash , could you explain please the
> meaning of función fi at the of scripts with commands if and while.
> Sometimes I read endif , does it have the same purpose?
That's exactly right.
When Stephen Bourne wrote his shell in the late 1970s, he decided to use
keywords spelled in reverse to mark the ends of blocks governed by what
the Bash manual calls "compound commands".
Specifically, he planned on:
if/fi
case/esac
do/od
But someone at the Bell Labs CSRC pointed out that there was already a
command called "od" (and there still is), and they refused to change its
name to accommodate Bourne's idea of symmetry. So "od" in Bourne's
shell was respelled as "done".
You can read more here.
https://en.wikipedia.org/wiki/Bourne_shell
In my opinion, Pascal-like keywords like "endif" would have been greatly
preferable and easier for novices to acquire, but it was considered good
fun around that time at the CSRC to punk on Pascal.
https://www.cs.virginia.edu/~evans/cs655/readings/bwk-on-pascal.html
This attitude was elevated to a religious belief by many lesser talents
in the Unix community, and consequently was taught to new Unix users as
gospel during a time when the user population of the system was
exploding. The rest is proverbial history.
Regards,
Branden
signature.asc
Description: PGP signature