

            if (1) --- conditional statement for Shell files         03/20/80


            _U_s_a_g_e

                 if <value>
                    then
                       { <command> }
                    else
                       { <command> }
                 fi


            _D_e_s_c_r_i_p_t_i_o_n

                 'If'  allows  users of the Shell's programming facilities to
                 execute commands conditionally, after  the  fashion  of  the
                 Algol 68 conditional clause.

                 The <value> after the if command may be any string; if it is
                 zero,  empty,  or  missing  altogether, it is interpreted as
                 false; otherwise, it is interpreted as true.  If <value>  is
                 true,  then  the  commands  after  the  keyword  'then'  are
                 executed; otherwise, the commands after the  keyword  'else'
                 are  executed.  In either alternative, any commands (includ-
                 ing nested if commands) may be used.

                 The keyword 'then' is optional.  The keyword 'else' and  its
                 associated  commands  may be omitted if no action is desired
                 when <value> is false.  The keyword 'fi' is mandatory.

                 'If' is not restricted to use in command files, and  so  may
                 produce  puzzling  results  when  used  incorrectly  from  a
                 terminal.  These can always be handled by typing a 'fi' com-
                 mand  or  by   generating   end-of-file   to   the   command
                 interpreter.


            _E_x_a_m_p_l_e_s

                 if [nargs]
                    set params = [args]
                 fi

                 if [eval i ">=" 10]
                    then
                       goto exit
                    else
                       set i = [eval i + 1]
                       goto loop
                 fi

                 if [flag]; then; echo "Success!"
                 else; echo "Failure..."
                 fi






            if (1)                        - 1 -                        if (1)




            if (1) --- conditional statement for Shell files         03/20/80


            _M_e_s_s_a_g_e_s

                 "Missing  'fi'"  if  end-of-file is reached on command input
                      before a matching 'fi' was found.


            _B_u_g_s

                 Redirectors in front of the  'else'  will  prevent  it  from
                 being recognized.

                 Typing  "if"  on  someone's terminal will cause the Shell to
                 ignore any command they type until an EOF  or  an  unmatched
                 'fi' is typed.


            _S_e_e _A_l_s_o

                 then (1), else (1), fi (1), case (1), goto (1), _U_s_e_r_'_s _G_u_i_d_e
                 _f_o_r _t_h_e _S_o_f_t_w_a_r_e _T_o_o_l_s _S_u_b_s_y_s_t_e_m _C_o_m_m_a_n_d _I_n_t_e_r_p_r_e_t_e_r






































            if (1)                        - 2 -                        if (1)


