On 7/1/25 7:50 PM, Dale wrote:
> It took me a while to figure out how important spaces are and where they
> have to be for things to work around the ifs.  Put a space in the wrong
> place, or leave one out where there should be one, it pukes on your
> keyboard. 


Spaces separate "words" in a command. And something that sometimes
surprises people is that in shell scripts, brackets, that is, [ and [[
are both "commands". They take a series of arguments.

For example,

if [ "$?" -eq "0" ] ; then

The "if" must be followed by a command to test its value. [ is a
command, and takes four arguments:

argument 1: $?
argument 2: -eq
argument 3: 0
argument 4: ]


The "]" argument tells it to stop reading arguments. :)

Using ; is equivalent to adding a newline, but prettier. It is legal to
do this:


if [ "$?" -eq "0" ];then

It just looks really ugly. :) :) :) Spaces help you read.



-- 
Eli Schwartz

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

Reply via email to