IEEE P1003.2a Draft 8 - December 1991 Copyright (c) 1991 by the Institute of Electrical and Electronics Engineers, Inc. 345 East 47th Street New York, NY 10017, USA All rights reserved as an unpublished work. This is an unapproved and unpublished IEEE Standards Draft, subject to change. The publication, distribution, or copying of this draft, as well as all derivative works based on this draft, is expressly prohibited except as set forth below. Permission is hereby granted for IEEE Standards Committee participants to reproduce this document for purposes of IEEE standardization activities only, and subject to the restrictions contained herein. Permission is hereby also granted for member bodies and technical committees of ISO and IEC to reproduce this document for purposes of developing a national position, subject to the restrictions contained herein. Permission is hereby also granted to the preceding entities to make limited copies of this document in an electronic form only for the stated activities. The following restrictions apply to reproducing or transmitting the document in any form: 1) all copies or portions thereof must identify the document's IEEE project number and draft number, and must be accompanied by this entire notice in a prominent location; 2) no portion of this document may be redistributed in any modified or abridged form without the prior approval of the IEEE Standards Department. Other entities seeking permission to reproduce this document, or any portion thereof, for standardization or other activities, must contact the IEEE Standards Department for the appropriate license. Use of information contained in this unapproved draft is at your own risk. IEEE Standards Department Copyright and Permissions 445 Hoes Lane, P.O. Box 1331 Piscataway, NJ 08855-1331, USA +1 (908) 562-3800 +1 (908) 562-1571 [FAX] P1003.2a/D8 Section 3: Revisions to Shell Command Language => 3.1 Shell Definitions. _M_o_d_i_f_y _t_h_e _c_o_n_t_e_n_t_s _o_f _c_l_a_u_s_e _3._1, _S_h_e_l_l _D_e_f_i_n_i_t_i_o_n_s, _t_o _a_d_d _t_h_e _f_o_l_l_o_w_i_n_g _d_e_f_i_n_i_t_i_o_n _i_n _t_h_e _c_o_r_r_e_c_t _s_o_r_t_e_d _o_r_d_e_r [_d_i_s_r_e_g_a_r_d_i_n_g _t_h_e _s_u_b_c_l_a_u_s_e _n_u_m_b_e_r _s_h_o_w_n _h_e_r_e]. 3.1 Shell Definitions 3.1.101 alias name: A word consisting solely of underscores, digits, and alphabetics from the portable character set (see 2.4) and any of the following characters: ! % , @ 7 Implementations may allow other characters within alias names as an 7 extension. 7 BEGIN_RATIONALE 7 _R_a_t_i_o_n_a_l_e_.__(_T_h_i_s__s_u_b_c_l_a_u_s_e__i_s__n_o_t__a__p_a_r_t__o_f__P_1_0_0_3_._2_a_) The characters allowed in alias names are from historical practice. END_RATIONALE => 3.3.1 Alias Substitution. _M_o_d_i_f_y _t_h_e _c_o_n_t_e_n_t_s _o_f _c_l_a_u_s_e _3._3, _T_o_k_e_n _R_e_c_o_g_n_i_t_i_o_n, _t_o _a_d_d _t_h_e _f_o_l_l_o_w_i_n_g _s_u_b_c_l_a_u_s_e: 3.3.1 Alias Substitution The processing of aliases shall be supported if the system supports the User Portability Utilities Option. Copyright (c) 1991 IEEE. All rights reserved. This is an unapproved IEEE Standards Draft, subject to change. 3.1 Shell Definitions 19 P1003.2a/D8 INFORMATION TECHNOLOGY--POSIX After a token has been delimited, but before applying the grammatical rules in 3.10, a resulting word that is identified to be the command name word of a simple command shall be examined to determine if it is an unquoted, valid alias name. However, reserved words in correct grammatical context shall not be candidates for alias substitution. A valid alias name (see 3.1.101) shall be one that has been defined by the alias utility (see 5.1) and not subsequently undefined using unalias (see 5.31). Implementations also may provide predefined valid aliases that are in effect when the shell is invoked. To prevent infinite loops in recursive aliasing, if the shell is not currently processing an alias of the same name, the word shall be replaced by the value of the alias; otherwise, it shall not be replaced. If the value of the alias replacing the word ends in a , the shell shall check the next command word for alias substitution; this process shall continue until a word is found that is not a valid alias or an alias value does not end in a . When used as specified by this standard, alias definitions shall not be inherited by separate invocations of the shell or by the utility execution environments invoked by the shell; see 3.12. BEGIN_RATIONALE _R_a_t_i_o_n_a_l_e_.__(_T_h_i_s__s_u_b_c_l_a_u_s_e__i_s__n_o_t__a__p_a_r_t__o_f__P_1_0_0_3_._2_a_) The alias capability was added in the UPE because it is widely used in historical implementations by interactive users. It was omitted from the base standard because it is not commonly used in application scripts, particularly since aliases are not passed to child shells. The definition of _a_l_i_a_s _n_a_m_e precludes an alias name containing a slash character. Since the text applies to the command words of simple commands, reserved words (in their proper places) cannot be confused with aliases. The placement of alias substitution in Token Recognition implies that it precedes all of the word expansion steps. An example concerning trailing _s and reserved words follows. If the user types: $ alias foo="/bin/ls " $ alias while="/" The effect of executing Copyright (c) 1991 IEEE. All rights reserved. This is an unapproved IEEE Standards Draft, subject to change. 20 3 Revisions to Shell Command Language PART 2: SHELL AND UTILITIES -- Amd. 1: UPE P1003.2a/D8 $ while true > do > echo "Hello, World" > done is a never-ending sequence of Hello, World strings to the screen. However, if the user types $ foo while the result will be an ls listing of /. Since the alias substitution for foo ends in a , the next word is checked for alias substitution. The next word, while, has also been aliased, so it is substituted as well. Since it is not in the proper position as a command word, it is not recognized as a reserved word. If the user types $ foo; while while retains its normal reserved-word properties. See the rationale for alias for a discussion of exportable aliases. END_RATIONALE 3.5.3 Variables => 3.5.3 Variables. _M_o_d_i_f_y _t_h_e _c_o_n_t_e_n_t_s _o_f _s_u_b_c_l_a_u_s_e _3._5._3, _V_a_r_i_a_b_l_e_s, _t_o _a_d_d _t_h_e _f_o_l_l_o_w_i_n_g _e_n_v_i_r_o_n_m_e_n_t _v_a_r_i_a_b_l_e_s _i_n _t_h_e _c_o_r_r_e_c_t _s_o_r_t_e_d _o_r_d_e_r. ENV This variable, when the shell is invoked, shall be subjected to parameter expansion (see 3.6.2) by the shell and the resulting value shall be used as a pathname of a file containing shell commands to execute in the current environment. The file need not be executable. If the 7 expanded value of ENV is not an absolute pathname, the 7 results are unspecified. ENV shall be ignored if the user's real and effective user IDs or real and effective group IDs are different. This standard specifies the 7 effects of this variable only for systems supporting the 7 User Portability Utilities Option. 7 Copyright (c) 1991 IEEE. All rights reserved. This is an unapproved IEEE Standards Draft, subject to change. 3.1 Shell Definitions 21