Changeset 46a2e9c for chapter07/profile.xml
- Timestamp:
- 01/06/2006 02:59:05 AM (19 years ago)
- Children:
- e1ca33a
- Parents:
- 1714f1a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
chapter07/profile.xml
r1714f1a r46a2e9c 1 1 <?xml version="1.0" encoding="ISO-8859-1"?> 2 <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [ 2 <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" 3 "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [ 3 4 <!ENTITY % general-entities SYSTEM "../general.ent"> 4 5 %general-entities; 5 6 ]> 7 6 8 <sect1 id="ch-scripts-profile"> 7 <title>The Bash Shell Startup Files</title> 8 <?dbhtml filename="profile.html"?> 9 <?dbhtml filename="profile.html"?> 9 10 10 <indexterm zone="ch-scripts-profile"><primary sortas="e-/etc/profile">/etc/profile</primary></indexterm>11 <title>The Bash Shell Startup Files</title> 11 12 12 <para>The shell program <command>/bin/bash</command> (hereafter 13 referred to as <quote>the shell</quote>) uses a collection of startup 14 files to help create an environment to run in. Each file has a 15 specific use and may affect login and interactive environments 16 differently. The files in the <filename 17 class="directory">/etc</filename> directory provide global settings. 18 If an equivalent file exists in the home directory, it may override 19 the global settings.</para> 13 <indexterm zone="ch-scripts-profile"> 14 <primary sortas="e-/etc/profile">/etc/profile</primary> 15 </indexterm> 20 16 21 <para>An interactive login shell is started after a successful login, 22 using <command>/bin/login</command>, by reading the 23 <filename>/etc/passwd</filename> file. An interactive non-login shell 24 is started at the command-line (e.g., 25 <prompt>[prompt]$</prompt><command>/bin/bash</command>). A 26 non-interactive shell is usually present when a shell script is 27 running. It is non-interactive because it is processing a script and 28 not waiting for user input between commands.</para> 17 <para>The shell program <command>/bin/bash</command> (hereafter referred to 18 as <quote>the shell</quote>) uses a collection of startup files to help 19 create an environment to run in. Each file has a specific use and may affect 20 login and interactive environments differently. The files in the <filename 21 class="directory">/etc</filename> directory provide global settings. If an 22 equivalent file exists in the home directory, it may override the global 23 settings.</para> 29 24 30 <para>For more information, see <command>info bash</command> under the 31 <emphasis>Bash Startup Files and Interactive Shells</emphasis> section.</para> 25 <para>An interactive login shell is started after a successful login, using 26 <command>/bin/login</command>, by reading the <filename>/etc/passwd</filename> 27 file. An interactive non-login shell is started at the command-line (e.g., 28 <prompt>[prompt]$</prompt><command>/bin/bash</command>). A non-interactive 29 shell is usually present when a shell script is running. It is non-interactive 30 because it is processing a script and not waiting for user input between 31 commands.</para> 32 32 33 <para>The files <filename>/etc/profile</filename> and 34 <filename>~/.bash_profile</filename> are read when the shell is 35 invoked as an interactive login shell.</para> 33 <para>For more information, see <command>info bash</command> under the 34 <emphasis>Bash Startup Files and Interactive Shells</emphasis> section.</para> 36 35 37 <para>The base <filename>/etc/profile</filename> below sets some 38 environment variables necessary for native language support. Setting 39 them properly results in:</para>36 <para>The files <filename>/etc/profile</filename> and 37 <filename>~/.bash_profile</filename> are read when the shell is 38 invoked as an interactive login shell.</para> 40 39 41 <itemizedlist> 42 <listitem><para>The output of programs translated into the native 43 language</para></listitem> 44 <listitem><para>Correct classification of characters into letters, digits and 45 other classes. This is necessary for <command>bash</command> to properly accept 46 non-ASCII characters in command lines in non-English locales</para></listitem> 47 <listitem><para>The correct alphabetical sorting order for the 48 country</para></listitem> 49 <listitem><para>Appropriate default paper size</para></listitem> 50 <listitem><para>Correct formatting of monetary, time, and date 51 values</para></listitem> 52 </itemizedlist> 40 <para>The base <filename>/etc/profile</filename> below sets some 41 environment variables necessary for native language support. Setting 42 them properly results in:</para> 53 43 54 <para>This script also sets the <envar>INPUTRC</envar> environment variable that 55 makes Bash and Readline use the <filename>/etc/inputrc</filename> file created 56 earlier.</para> 44 <itemizedlist> 45 <listitem> 46 <para>The output of programs translated into the native language</para> 47 </listitem> 48 <listitem> 49 <para>Correct classification of characters into letters, digits and other 50 classes. This is necessary for <command>bash</command> to properly accept 51 non-ASCII characters in command lines in non-English locales</para> 52 </listitem> 53 <listitem> 54 <para>The correct alphabetical sorting order for the country</para> 55 </listitem> 56 <listitem> 57 <para>Appropriate default paper size</para> 58 </listitem> 59 <listitem> 60 <para>Correct formatting of monetary, time, and date values</para> 61 </listitem> 62 </itemizedlist> 57 63 58 <para>Replace <replaceable>[ll]</replaceable> below with the 59 two-letter code for the desired language (e.g., <quote>en</quote>) and 60 <replaceable>[CC]</replaceable> with the two-letter code for the 61 appropriate country (e.g., <quote>GB</quote>). 62 <replaceable>[charmap]</replaceable> should be replaced with the 63 canonical charmap for your chosen locale.</para> 64 <para>This script also sets the <envar>INPUTRC</envar> environment variable that 65 makes Bash and Readline use the <filename>/etc/inputrc</filename> file created 66 earlier.</para> 64 67 65 <para>The list of all locales supported by Glibc can be obtained by running 66 the following command:</para> 68 <para>Replace <replaceable>[ll]</replaceable> below with the two-letter code 69 for the desired language (e.g., <quote>en</quote>) and 70 <replaceable>[CC]</replaceable> with the two-letter code for the appropriate 71 country (e.g., <quote>GB</quote>). <replaceable>[charmap]</replaceable> should 72 be replaced with the canonical charmap for your chosen locale. Optional 73 modifiers such as <quote>@euro</quote> may also be present.</para> 74 75 <para>The list of all locales supported by Glibc can be obtained by running 76 the following command:</para> 67 77 68 78 <screen role="nodump"><userinput>locale -a</userinput></screen> 69 79 70 <para>Locales can have a number of synonyms, e.g. <quote>ISO-8859-1</quote> is 71 also referred to as <quote>iso8859-1</quote> and <quote>iso88591</quote>. 72 Some applications cannot handle the various synonyms correctly, so it is safest 73 to choose the canonical name for a particular locale. To determine the 74 canonical name, run the following command, where 75 <replaceable>[locale name]</replaceable> is the output given by 76 <command>locale -a</command> for your preferred locale 77 (<quote>en_GB.iso88591</quote> in our example).</para> 80 <para>Charmaps can have a number of aliases, e.g., <quote>ISO-8859-1</quote> 81 is also referred to as <quote>iso8859-1</quote> and <quote>iso88591</quote>. 82 Some applications cannot handle the various synonyms correctly (e.g., require 83 that <quote>UTF-8</quote> is written as <quote>UTF-8</quote>, not 84 <quote>utf8</quote>), so it is safest in most 85 cases to choose the canonical name for a particular locale. To determine 86 the canonical name, run the following command, where <replaceable>[locale 87 name]</replaceable> is the output given by <command>locale -a</command> for 88 your preferred locale (<quote>en_GB.iso88591</quote> in our example).</para> 78 89 79 90 <screen role="nodump"><userinput>LC_ALL=<replaceable>[locale name]</replaceable> locale charmap</userinput></screen> 80 91 81 <para>For the <quote>en_GB.iso88591</quote> locale, the above command82 will print:</para>92 <para>For the <quote>en_GB.iso88591</quote> locale, the above command 93 will print:</para> 83 94 84 <screen> ISO-8859-1</screen>95 <screen><computeroutput>ISO-8859-1</computeroutput></screen> 85 96 86 <para>This results in a final locale setting of <quote>en_GB.ISO-8859-1</quote>.</para> 97 <para>This results in a final locale setting of <quote>en_GB.ISO-8859-1</quote>. 98 It is important that the locale found using the heuristic above is tested prior 99 to it being added to the Bash startup files:</para> 87 100 88 <para>Once the proper locale settings have been determined, create the 89 <filename>/etc/profile</filename> file:</para> 101 <screen role="nodump"><userinput>LC_ALL=[locale name] locale country 102 LC_ALL=[locale name] locale language 103 LC_ALL=[locale name] locale charmap 104 LC_ALL=[locale name] locale int_curr_symbol 105 LC_ALL=[locale name] locale int_prefix</userinput></screen> 106 107 <para>The above commands should print the country and language names, the 108 character encoding used by the locale, the local currency and the prefix to dial 109 before the telephone number in order to get into the country. If any of the 110 commands above fail with a message similar to the one shown below, this means 111 that your locale was either not installed in Chapter 6 or is not supported by 112 the default installation of Glibc.</para> 113 114 <screen><computeroutput>locale: Cannot set LC_* to default locale: No such file or directory</computeroutput></screen> 115 116 <para>If this happens, you should either install the desired locale using the 117 <command>localedef</command> command, or consider choosing a different locale. 118 Further instructions assume that there are no such error messages from 119 Glibc.</para> 120 121 <!-- FIXME: the xlib example will became obsolete real soon --> 122 <para>Some packages beyond LFS may also lack support for your chosen locale. One 123 example is the X library (part of the X Window System), which outputs the 124 following error message:</para> 125 126 <screen><computeroutput>Warning: locale not supported by Xlib, locale set to C</computeroutput></screen> 127 128 <para>Sometimes it is possible to fix this by removing the charmap part of the 129 locale specification, as long as that does not change the character map that 130 Glibc associates with the locale (this can be checked by running the 131 <command>locale charmap</command> command in both locales). For example, one 132 would have to change "de_DE.ISO-8859-15@euro" to 133 "de_DE@euro" in order to get this locale recognized by Xlib.</para> 134 135 <para>Other packages can also function incorrectly (but may not necessarily 136 display any error messages) if the locale name does not meet their expectations. 137 In those cases, investigating how other Linux distributions support your locale 138 might provide some useful information.</para> 139 140 <para>Once the proper locale settings have been determined, create the 141 <filename>/etc/profile</filename> file:</para> 90 142 91 143 <screen><userinput>cat > /etc/profile << "EOF" 92 144 <literal># Begin /etc/profile 93 145 94 export LANG=<replaceable>[ll]</replaceable>_<replaceable>[CC]</replaceable>.<replaceable>[charmap]</replaceable> 146 export LANG=<replaceable>[ll]</replaceable>_<replaceable>[CC]</replaceable>.<replaceable>[charmap]</replaceable><replaceable>[@modifiers]</replaceable> 95 147 export INPUTRC=/etc/inputrc 96 148 … … 98 150 EOF</userinput></screen> 99 151 100 <note><para>The <quote>C</quote> (default) and <quote>en_US</quote> 101 (the recommended one for United States English users) locales are 102 different.</para></note> 152 <para>The <quote>C</quote> (default) and <quote>en_US</quote> (the recommended 153 one for United States English users) locales are different. <quote>C</quote> 154 uses the US-ASCII 7-bit character set, and treats bytes with the high bit set 155 as invalid characters. That's why, e.g., the <command>ls</command> command 156 substitutes them with question marks in that locale. Also, an attempt to send 157 mail with such characters from Mutt or Pine results in non-RFC-conforming 158 messages being sent (the charset in the outgoing mail is indicated as <quote>unknown 159 8-bit</quote>). So you can use the <quote>C</quote> locale only if you are sure that 160 you will never need 8-bit characters.</para> 103 161 104 <para>Setting the keyboard layout, screen font, and 105 locale-related environment variables are the only internationalization 106 steps needed to support locales that use ordinary single-byte 107 encodings and left-to-right writing direction. More complex cases 108 (including UTF-8 based locales) require additional steps and 109 additional patches because many applications tend to not work properly 110 under such conditions. These steps and patches are not included in 111 the LFS book and such locales are not yet supported by LFS.</para> 162 <para>UTF-8 based locales are not supported well by many programs. E.g., the 163 <command>watch</command> program displays only ASCII characters in UTF-8 164 locales and has no such restriction in traditional 8-bit locales like en_US. 165 Without patches and/or installing software beyond BLFS, in UTF-8 based locales 166 you will not be able to do such basic tasks as printing plain-text files from 167 the command line, recording Windows-readable CDs with filenames containing 168 non-ASCII characters, viewing ID3v1 tags in MP3 files and so on. Work is in 169 progress to document and, if possible, fix such problems, see 170 <ulink url="&blfs-root;view/svn/introduction/locale-issues.html"/>. 171 It is, however, safe to use UTF-8 based locales if you are going to use only 172 KDE or GNOME and never open the terminal.</para> 173 <!-- All abovementioned problems except "watch" have a known fix beyond BLFS --> 112 174 113 175 </sect1> 114
Note:
See TracChangeset
for help on using the changeset viewer.