No specific user configuration
[platform/upstream/bash.git] / doc / article.txt
1
2
3
4
5
6
7
8
9
10                    Bash - The GNU shell*
11
12
13                          Chet Ramey
14               Case Western Reserve University
15                       chet@po.cwru.edu
16
17
18
19
20
21
22 _\b1.  _\bI_\bn_\bt_\br_\bo_\bd_\bu_\bc_\bt_\bi_\bo_\bn
23
24      _\bB_\ba_\bs_\bh is the shell,  or  command  language  interpreter,
25 that  will  appear in the GNU operating system.  The name is
26 an acronym for the "Bourne-Again  SHell",  a  pun  on  Steve
27 Bourne,  the  author  of  the direct ancestor of the current
28 UNIX|\b- shell /_\bb_\bi_\bn/_\bs_\bh, which appeared in the  Seventh  Edition
29 Bell Labs Research version of UNIX.
30
31      Bash is an sh-compatible shell that incorporates useful
32 features  from  the  Korn shell (ksh) and the C shell (csh),
33 described later in this article.  It is ultimately  intended
34 to  be  a  conformant implementation of the IEEE POSIX Shell
35 and Utilities specification (IEEE Working Group 1003.2).  It
36 offers  functional improvements over sh for both interactive
37 and programming use.
38
39      While the GNU operating system will most likely include
40 a  version  of  the  Berkeley  shell  csh,  Bash will be the
41 default shell.  Like other GNU software, Bash is quite port-
42 able.  It currently runs on nearly every version of UNIX and
43 a few other operating systems -  an  independently-supported
44 port  exists  for OS/2, and there are rumors of ports to DOS
45 and Windows NT.  Ports to UNIX-like systems such as QNX  and
46 Minix are part of the distribution.
47
48      The original author of Bash was Brian Fox, an  employee
49 of  the Free Software Foundation.  The current developer and
50 maintainer is Chet Ramey, a  volunteer  who  works  at  Case
51 Western Reserve University.
52
53 _\b2.  _\bW_\bh_\ba_\bt'_\bs _\bP_\bO_\bS_\bI_\bX, _\ba_\bn_\by_\bw_\ba_\by?
54
55      _\bP_\bO_\bS_\bI_\bX is a name originally coined by  Richard  Stallman
56 _________________________
57 *An earlier version of this  article  appeared  in  The
58 Linux Journal.
59 |\b- UNIX is a trademark of Bell Laboratories.
60
61
62
63
64                       October 28, 1994
65
66
67
68
69
70                            - 2 -
71
72
73 for a family of open system standards based on UNIX.   There
74 are  a  number  of  aspects  of UNIX under consideration for
75 standardization, from the basic system services at the  sys-
76 tem  call  and  C library level to applications and tools to
77 system administration and management.  Each  area  of  stan-
78 dardization  is  assigned  to  a  working  group in the 1003
79 series.
80
81      The  POSIX  Shell  and  Utilities  standard  has   been
82 developed by IEEE Working Group 1003.2 (POSIX.2).|\b=  It  con-
83 centrates  on  the command interpreter interface and utility
84 programs commonly executed from the command line or by other
85 programs.   An  initial  version  of  the  standard has been
86 approved and published by the IEEE, and  work  is  currently
87 underway to update it.  There are four primary areas of work
88 in the 1003.2 standard:
89
90 o\b+    Aspects of the shell's syntax and command language.   A
91      number  of  special  builtins  such  as _\bc_\bd and _\be_\bx_\be_\bc are
92      being specified as part of the shell, since their func-
93      tionality  usually  cannot be implemented by a separate
94      executable;
95
96 o\b+    A set of utilities to be called by  shell  scripts  and
97      applications.   Examples are programs like _\bs_\be_\bd, _\bt_\br, and
98      _\ba_\bw_\bk.  Utilities commonly implemented as shell  builtins
99      are  described  in this section, such as _\bt_\be_\bs_\bt and _\bk_\bi_\bl_\bl.
100      An expansion of this section's scope, termed  the  User
101      Portability   Extension,   or   UPE,  has  standardized
102      interactive programs such as _\bv_\bi and _\bm_\ba_\bi_\bl_\bx;
103
104 o\b+    A group of functional interfaces to  services  provided
105      by  the  shell,  such  as  the  traditional  system() C
106      library function.  There are functions to perform shell
107      word expansions, perform filename expansion (_\bg_\bl_\bo_\bb_\bb_\bi_\bn_\bg),
108      obtain values of  POSIX.2  system  configuration  vari-
109      ables,   retrieve   values   of  environment  variables
110      (getenv()), _\ba_\bn_\bd _\bo_\bt_\bh_\be_\br _\bs_\be_\br_\bv_\bi_\bc_\be_\bs;
111
112 o\b+    A suite of "development" utilities  such  as  _\bc_\b8_\b9  (the
113      POSIX.2 version of _\bc_\bc), and _\by_\ba_\bc_\bc.
114
115      Bash is concerned  with  the  aspects  of  the  shell's
116 behavior defined by POSIX.2.  The shell command language has
117 of course been standardized, including the basic  flow  con-
118 trol  and  program execution constructs, I/O redirection and
119 pipelining, argument handling, variable expansion, and quot-
120 ing.   The  _\bs_\bp_\be_\bc_\bi_\ba_\bl  builtins,  which must be implemented as
121 part of the shell to provide the desired functionality,  are
122 _________________________
123 |\b=IEEE, _\bI_\bE_\bE_\bE  _\bS_\bt_\ba_\bn_\bd_\ba_\br_\bd  _\bf_\bo_\br  _\bI_\bn_\bf_\bo_\br_\bm_\ba_\bt_\bi_\bo_\bn  _\bT_\be_\bc_\bh_\bn_\bo_\bl_\bo_\bg_\by  --
124 _\bP_\bo_\br_\bt_\ba_\bb_\bl_\be  _\bO_\bp_\be_\br_\ba_\bt_\bi_\bn_\bg  _\bS_\by_\bs_\bt_\be_\bm  _\bI_\bn_\bt_\be_\br_\bf_\ba_\bc_\be  (_\bP_\bO_\bS_\bI_\bX) _\bP_\ba_\br_\bt _\b2:
125 _\bS_\bh_\be_\bl_\bl _\ba_\bn_\bd _\bU_\bt_\bi_\bl_\bi_\bt_\bi_\be_\bs, 1992.
126
127
128
129
130                       October 28, 1994
131
132
133
134
135
136                            - 3 -
137
138
139 specified as being part of the shell; examples of these  are
140 _\be_\bv_\ba_\bl  and _\be_\bx_\bp_\bo_\br_\bt.  Other utilities appear in the sections of
141 POSIX.2 not devoted to the shell which are commonly (and  in
142 some cases must be) implemented as builtin commands, such as
143 _\br_\be_\ba_\bd and  _\bt_\be_\bs_\bt.   POSIX.2  also  specifies  aspects  of  the
144 shell's  interactive  behavior as part of the UPE, including
145 job control and command line editing.  Interestingly enough,
146 only  _\bv_\bi-style line editing commands have been standardized;
147 _\be_\bm_\ba_\bc_\bs editing commands were left out due to objections.
148
149      While POSIX.2 includes much of what the shell has trad-
150 itionally  provided, some important things have been omitted
151 as being "beyond its scope."  There  is,  for  instance,  no
152 mention  of a difference between a _\bl_\bo_\bg_\bi_\bn shell and any other
153 interactive shell (since POSIX.2 does not  specify  a  login
154 program).   No fixed startup files are defined, either - the
155 standard does not mention ._\bp_\br_\bo_\bf_\bi_\bl_\be.
156
157 _\b3.  _\bB_\ba_\bs_\bi_\bc _\bB_\ba_\bs_\bh _\bf_\be_\ba_\bt_\bu_\br_\be_\bs
158
159      Since the Bourne shell provides Bash with most  of  its
160 philosophical  underpinnings,  Bash  inherits  most  of  its
161 features and functionality from sh.  Bash implements all  of
162 the  traditional sh flow control constructs (_\bf_\bo_\br, _\bi_\bf, _\bw_\bh_\bi_\bl_\be,
163 etc.).  All of the Bourne shell  builtins,  including  those
164 not  specified  in  the  POSIX.2  standard,  appear in Bash.
165 Shell _\bf_\bu_\bn_\bc_\bt_\bi_\bo_\bn_\bs, introduced  in  the  SVR2  version  of  the
166 Bourne  shell, are similar to shell scripts, but are defined
167 using a special syntax and are executed in the same  process
168 as the calling shell.  Bash has shell functions which behave
169 in a fashion upward-compatible with sh functions.  There are
170 certain shell variables that Bash interprets in the same way
171 as sh, such as _\bP_\bS_\b1, _\bI_\bF_\bS, and _\bP_\bA_\bT_\bH.  Bash  implements  essen-
172 tially  the  same  grammar, parameter and variable expansion
173 semantics, redirection, and quoting  as  the  Bourne  shell.
174 Where  differences  appear  between the POSIX.2 standard and
175 traditional sh behavior, Bash follows POSIX.
176
177      The Korn Shell (ksh) is  a  descendent  of  the  Bourne
178 shell  written at AT&T Bell Laboratories by David Korn|\b-.  It
179 provides a number of useful features  that  POSIX  and  Bash
180 have adopted.  Many of the interactive facilities in POSIX.2
181 have their roots in the ksh: for example, the POSIX and  ksh
182 job  control  facilities are nearly identical. Bash includes
183 features from the Korn Shell for both  interactive  use  and
184 shell programming.  For programming, Bash provides variables
185 such as _\bR_\bA_\bN_\bD_\bO_\bM and _\bR_\bE_\bP_\bL_\bY, the _\bt_\by_\bp_\be_\bs_\be_\bt builtin,  the  ability
186 to  remove  substrings from variables based on patterns, and
187 shell arithmetic.  _\bR_\bA_\bN_\bD_\bO_\bM expands to a  random  number  each
188 time it is referenced; assigning a value to _\bR_\bA_\bN_\bD_\bO_\bM seeds the
189 _________________________
190 |\b-Morris Bolsky and David Korn,  _\bT_\bh_\be  _\bK_\bo_\br_\bn_\bS_\bh_\be_\bl_\bl  _\bC_\bo_\bm_\bm_\ba_\bn_\bd
191 _\ba_\bn_\bd _\bP_\br_\bo_\bg_\br_\ba_\bm_\bm_\bi_\bn_\bg _\bL_\ba_\bn_\bg_\bu_\ba_\bg_\be, Prentice Hall, 1989.
192
193
194
195
196                       October 28, 1994
197
198
199
200
201
202                            - 4 -
203
204
205 random number generator.  _\bR_\bE_\bP_\bL_\bY is the default variable used
206 by  the  _\br_\be_\ba_\bd builtin when no variable names are supplied as
207 arguments.  The _\bt_\by_\bp_\be_\bs_\be_\bt builtin is used to define  variables
208 and  give them attributes such as readonly.  Bash arithmetic
209 allows the evaluation of an expression and the  substitution
210 of the result.  Shell variables may be used as operands, and
211 the result of an expression may be assigned to  a  variable.
212 Nearly  all  of the operators from the C language are avail-
213 able, with the same precedence rules:
214 \e9     $ echo $((3 + 5 * 32))
215      163
216 \e9
217 For interactive use, Bash implements ksh-style  aliases  and
218 builtins  such  as  _\bf_\bc  (discussed  below)  and  _\bj_\bo_\bb_\bs.  Bash
219 aliases allow a string to be substituted for a command name.
220 They  can  be  used  to create a mnemonic for a UNIX command
221 name (alias del=rm), to expand a single word  to  a  complex
222 command (alias news='xterm -g 80x45 -title trn -e trn -e -S1
223 -N &'), or to ensure that a command is invoked with a  basic
224 set of options (alias ls="/bin/ls -F").
225
226      The C shell (csh)|\b-,  originally  written  by  Bill  Joy
227 while  at Berkeley, is widely used and quite popular for its
228 interactive facilities.  Bash includes a csh-compatible his-
229 tory  expansion  mechanism  ("!  history"), brace expansion,
230 access to a stack of directories via the  _\bp_\bu_\bs_\bh_\bd,  _\bp_\bo_\bp_\bd,  and
231 _\bd_\bi_\br_\bs  builtins, and tilde expansion, to generate users' home
232 directories.  Tilde expansion has also been adopted by  both
233 the Korn Shell and POSIX.2.
234
235      There were certain areas in which  POSIX.2  felt  stan-
236 dardization  was  necessary,  but no existing implementation
237 provided the proper behavior.  The  working  group  invented
238 and  standardized  functionality  in these areas, which Bash
239 implements.  The _\bc_\bo_\bm_\bm_\ba_\bn_\bd builtin was invented so that  shell
240 functions could be written to replace builtins; it makes the
241 capabilities of the builtin available to the function.   The
242 reserved  word "!" was added to negate the return value of a
243 command or pipeline; it was nearly impossible to express "if
244 not  x" cleanly using the sh language.  There exist multiple
245 incompatible implementations  of  the  _\bt_\be_\bs_\bt  builtin,  which
246 tests  files  for  type  and  other  attributes and performs
247 arithmetic and string comparisons.  POSIX considered none of
248 these  correct,  so  the  standard behavior was specified in
249 terms of the number of arguments to  the  command.   POSIX.2
250 dictates  exactly  what will happen when four or fewer argu-
251 ments are given to _\bt_\be_\bs_\bt, and leaves the  behavior  undefined
252 when  more  arguments  are  supplied.  Bash uses the POSIX.2
253 _________________________
254 |\b-Bill Joy, An Introduction to the C Shell, _\bU_\bN_\bI_\bX  _\bU_\bs_\be_\br'_\bs
255 _\bS_\bu_\bp_\bp_\bl_\be_\bm_\be_\bn_\bt_\ba_\br_\by  _\bD_\bo_\bc_\bu_\bm_\be_\bn_\bt_\bs,  University  of California at
256 Berkeley, 1986.
257
258
259
260
261                       October 28, 1994
262
263
264
265
266
267                            - 5 -
268
269
270 algorithm, which was conceived by David Korn.
271
272 _\b3._\b1.  _\bF_\be_\ba_\bt_\bu_\br_\be_\bs _\bn_\bo_\bt _\bi_\bn _\bt_\bh_\be _\bB_\bo_\bu_\br_\bn_\be _\bS_\bh_\be_\bl_\bl
273
274      There are a number of minor  differences  between  Bash
275 and  the  version  of  sh  present on most other versions of
276 UNIX.  The majority of these are due to the POSIX  standard,
277 but some are the result of Bash adopting features from other
278 shells.  For instance, Bash includes the  new  "!"  reserved
279 word,  the  _\bc_\bo_\bm_\bm_\ba_\bn_\bd builtin, the ability of the _\br_\be_\ba_\bd builtin
280 to correctly return a line ending with a backslash, symbolic
281 arguments  to the _\bu_\bm_\ba_\bs_\bk builtin, variable substring removal,
282 a way to get the length of a variable, and the new algorithm
283 for  the  _\bt_\be_\bs_\bt  builtin  from  the POSIX.2 standard, none of
284 which appear in sh.
285
286      Bash also implements the "$(...)" command  substitution
287 syntax,  which  supersedes  the  sh  `...`  construct.   The
288 "$(...)" construct expands to the output of the command con-
289 tained   within  the  parentheses,  with  trailing  newlines
290 removed.  The sh syntax is accepted for  backwards  compati-
291 bility, but the "$(...)" form is preferred because its quot-
292 ing rules are much simpler and it is easier to nest.
293
294      The Bourne shell does  not  provide  such  features  as
295 brace  expansion,  the  ability  to  define a variable and a
296 function with the same name, local variables in shell  func-
297 tions, the ability to enable and disable individual builtins
298 or write a function to replace a  builtin,  or  a  means  to
299 export a shell function to a child process.
300
301      Bash has closed a long-standing shell security hole  by
302 not  using  the $_\bI_\bF_\bS variable to split each word read by the
303 shell, but splitting only the results of expansion (ksh  and
304 the  4.4  BSD  sh have fixed this as well).  Useful behavior
305 such as a means to abort execution of a script read with the
306 "."  command  using  the  return  builtin  or  automatically
307 exporting variables in the shell's environment  to  children
308 is  also  not  present in the Bourne shell.  Bash provides a
309 much more powerful environment for both interactive use  and
310 programming.
311
312 _\b4.  _\bB_\ba_\bs_\bh-_\bs_\bp_\be_\bc_\bi_\bf_\bi_\bc _\bF_\be_\ba_\bt_\bu_\br_\be_\bs
313
314      This section details a few of the features  which  make
315 Bash unique.  Most of them provide improved interactive use,
316 but a few programming  improvements  are  present  as  well.
317 Full descriptions of these features can be found in the Bash
318 documentation.
319
320 _\b4._\b1.  _\bS_\bt_\ba_\br_\bt_\bu_\bp _\bF_\bi_\bl_\be_\bs
321
322      Bash executes  startup  files  differently  than  other
323 shells.   The  Bash behavior is a compromise between the csh
324
325
326
327                       October 28, 1994
328
329
330
331
332
333                            - 6 -
334
335
336 principle of startup files with  fixed  names  executed  for
337 each shell and the sh "minimalist" behavior.  An interactive
338 instance of Bash started as a login shell reads and executes
339 ~/._\bb_\ba_\bs_\bh__\bp_\br_\bo_\bf_\bi_\bl_\be  (the  file .bash_profile in the user's home
340 directory), if it exists.  An  interactive  non-login  shell
341 reads  and executes ~/._\bb_\ba_\bs_\bh_\br_\bc.  A non-interactive shell (one
342 begun to execute a shell script, for example) reads no fixed
343 startup  file,  but  uses the value of the variable $_\bE_\bN_\bV, if
344 set, as the name of a startup file.   The  ksh  practice  of
345 reading  $_\bE_\bN_\bV  for every shell, with the accompanying diffi-
346 culty of defining the proper  variables  and  functions  for
347 interactive  and  non-interactive  shells or having the file
348 read only for interactive shells, was  considered  too  com-
349 plex.   Ease  of  use won out here.  Interestingly, the next
350 release of ksh will change to reading $_\bE_\bN_\bV only for interac-
351 tive shells.
352
353 _\b4._\b2.  _\bN_\be_\bw _\bB_\bu_\bi_\bl_\bt_\bi_\bn _\bC_\bo_\bm_\bm_\ba_\bn_\bd_\bs
354
355      There are a few builtins which are  new  or  have  been
356 extended  in  Bash.   The _\be_\bn_\ba_\bb_\bl_\be builtin allows builtin com-
357 mands to be turned on and off arbitrarily.  To use the  ver-
358 sion  of  _\be_\bc_\bh_\bo found in a user's search path rather than the
359 Bash builtin, enable -n echo  suffices.   The  _\bh_\be_\bl_\bp  builtin
360 provides  quick  synopses  of  the  shell facilities without
361 requiring access to a manual page.  _\bB_\bu_\bi_\bl_\bt_\bi_\bn  is  similar  to
362 _\bc_\bo_\bm_\bm_\ba_\bn_\bd  in  that  it  bypasses shell functions and directly
363 executes builtin commands.  Access to a csh-style  stack  of
364 directories  is provided via the _\bp_\bu_\bs_\bh_\bd, _\bp_\bo_\bp_\bd, and _\bd_\bi_\br_\bs buil-
365 tins.  _\bP_\bu_\bs_\bh_\bd and _\bp_\bo_\bp_\bd insert and remove directories from the
366 stack,  respectively, and _\bd_\bi_\br_\bs lists the stack contents.  On
367 systems that allow fine-grained control  of  resources,  the
368 _\bu_\bl_\bi_\bm_\bi_\bt  builtin  can be used to tune these settings.  _\bU_\bl_\bi_\bm_\bi_\bt
369 allows a user to control, among other things,  whether  core
370 dumps  are  to  be generated, how much memory the shell or a
371 child process is allowed to allocate, and how large  a  file
372 created  by  a  child process can grow.  The _\bs_\bu_\bs_\bp_\be_\bn_\bd command
373 will stop the shell process when job control is active; most
374 other  shells  do  not  allow  themselves to be stopped like
375 that.  _\bT_\by_\bp_\be, the Bash answer to _\bw_\bh_\bi_\bc_\bh and _\bw_\bh_\be_\bn_\bc_\be, shows what
376 will happen when a word is typed as a command:
377 \e9     $ type export
378      export is a shell builtin
379      $ type -t export
380      builtin
381      $ type bash
382      bash is /bin/bash
383      $ type cd
384      cd is a function
385      cd ()
386      {
387          builtin cd ${1+"$@"} && xtitle $HOST: $PWD
388      }
389 \e9
390
391
392                       October 28, 1994
393
394
395
396
397
398                            - 7 -
399
400
401 Various modes tell what a command word  is  (reserved  word,
402 alias,  function,  builtin,  or  file) or which version of a
403 command will be executed based  on  a  user's  search  path.
404 Some  of  this functionality has been adopted by POSIX.2 and
405 folded into the _\bc_\bo_\bm_\bm_\ba_\bn_\bd utility.
406
407 _\b4._\b3.  _\bE_\bd_\bi_\bt_\bi_\bn_\bg _\ba_\bn_\bd _\bC_\bo_\bm_\bp_\bl_\be_\bt_\bi_\bo_\bn
408
409      One area in which Bash shines is command line  editing.
410 Bash  uses  the _\br_\be_\ba_\bd_\bl_\bi_\bn_\be library to read and edit lines when
411 interactive.  Readline is  a  powerful  and  flexible  input
412 facility that a user can configure to individual tastes.  It
413 allows lines to be edited using either emacs or vi commands,
414 where  those  commands are appropriate.  The full capability
415 of emacs is not present - there is no way to execute a named
416 command  with  M-x, for instance - but the existing commands
417 are more than adequate.  The vi mode is compliant  with  the
418 command line editing standardized by POSIX.2.
419
420      Readline is fully customizable.   In  addition  to  the
421 basic commands and key bindings, the library allows users to
422 define additional key bindings using a  startup  file.   The
423 _\bi_\bn_\bp_\bu_\bt_\br_\bc file, which defaults to the file ~/._\bi_\bn_\bp_\bu_\bt_\br_\bc, is read
424 each time readline initializes, permitting users to maintain
425 a  consistent  interface across a set of programs.  Readline
426 includes an extensible interface, so each program using  the
427 library  can  add  its  own  bindable  commands and program-
428 specific key bindings.  Bash uses this facility to add bind-
429 ings that perform history expansion or shell word expansions
430 on the current input line.
431
432      Readline interprets a number of variables which further
433 tune  its  behavior.   Variables exist to control whether or
434 not eight-bit characters are directly read as input or  con-
435 verted  to  meta-prefixed key sequences (a meta-prefixed key
436 sequence consists of  the  character  with  the  eighth  bit
437 zeroed,  preceded  by  the  _\bm_\be_\bt_\ba-_\bp_\br_\be_\bf_\bi_\bx  character,  usually
438 escape,  which  selects  an  alternate  keymap),  to  decide
439 whether  to  output  characters  with  the  eighth  bit  set
440 directly or as a meta-prefixed key sequence, whether or  not
441 to  wrap  to  a  new screen line when a line being edited is
442 longer than the screen width, the keymap to which subsequent
443 key  bindings  should apply, or even what happens when read-
444 line wants to ring the terminal's bell.  All of these  vari-
445 ables can be set in the inputrc file.
446
447      The startup file understands a set of  C  preprocessor-
448 like  conditional  constructs  which  allow variables or key
449 bindings to be assigned based on the application using read-
450 line,  the  terminal  currently  being  used, or the editing
451 mode.  Users can add program-specific bindings to make their
452 lives easier:  I have bindings that let me edit the value of
453 $_\bP_\bA_\bT_\bH and double-quote the current or previous word:
454 \e9     # Macros that are convenient for shell interaction
455
456
457 \e9                      October 28, 1994
458
459
460
461
462
463                            - 8 -
464
465
466      $if Bash
467      # edit the path
468      "\C-xp": "PATH=${PATH}\e\C-e\C-a\ef\C-f"
469      # prepare to type a quoted word -- insert open and close double
470      # quotes and move to just after the open quote
471      "\C-x\"": "\"\"\C-b"
472      # Quote the current or previous word
473      "\C-xq": "\eb\"\ef\""
474      $endif
475 \e9
476 There is a readline command to re-read the  file,  so  users
477 can  edit  the  file, change some bindings, and begin to use
478 them almost immediately.
479
480      Bash implements the _\bb_\bi_\bn_\bd builtin for more  dyamic  con-
481 trol  of  readline  than  the startup file permits.  _\bB_\bi_\bn_\bd is
482 used in several ways.  In _\bl_\bi_\bs_\bt  mode,  it  can  display  the
483 current  key  bindings, list all the readline editing direc-
484 tives available for binding, list which keys invoke a  given
485 directive,  or  output  the current set of key bindings in a
486 format that can be incorporated  directly  into  an  inputrc
487 file.   In  _\bb_\ba_\bt_\bc_\bh  mode,  it  reads a series of key bindings
488 directly from a file and passes them to  readline.   In  its
489 most  common usage, _\bb_\bi_\bn_\bd takes a single string and passes it
490 directly to readline, which interprets the line as if it had
491 just been read from the inputrc file.  Both key bindings and
492 variable assignments may appear in the string given to _\bb_\bi_\bn_\bd.
493
494      The readline library also  provides  an  interface  for
495 _\bw_\bo_\br_\bd  _\bc_\bo_\bm_\bp_\bl_\be_\bt_\bi_\bo_\bn.   When  the  _\bc_\bo_\bm_\bp_\bl_\be_\bt_\bi_\bo_\bn character (usually
496 TAB) is typed, readline looks at the  word  currently  being
497 entered  and  computes  the  set  of  filenames of which the
498 current word is a valid prefix.  If there is only one possi-
499 ble  completion,  the  rest  of  the characters are inserted
500 directly,  otherwise  the  common  prefix  of  the  set   of
501 filenames  is added to the current word.  A second TAB char-
502 acter entered  immediately  after  a  non-unique  completion
503 causes  readline  to list the possible completions; there is
504 an option to have the list displayed immediately.   Readline
505 provides  hooks  so  that  applications can provide specific
506 types of completion before the default  filename  completion
507 is attempted.  This is quite flexible, though it is not com-
508 pletely user-programmable.  Bash, for example, can  complete
509 filenames, command names (including aliases, builtins, shell
510 reserved words, shell functions, and  executables  found  in
511 the file system), shell variables, usernames, and hostnames.
512 It uses a set of heuristics that, while not perfect, is gen-
513 erally  quite good at determining what type of completion to
514 attempt.
515
516 _\b4._\b4.  _\bH_\bi_\bs_\bt_\bo_\br_\by
517
518      Access to the list of commands previously entered  (the
519 _\bc_\bo_\bm_\bm_\ba_\bn_\bd  _\bh_\bi_\bs_\bt_\bo_\br_\by)  is  provided  jointly  by  Bash  and  the
520
521
522 \e9                      October 28, 1994
523
524
525
526
527
528                            - 9 -
529
530
531 readline  library.   Bash  provides  variables   ($HISTFILE,
532 $HISTSIZE, and $HISTCONTROL) and the _\bh_\bi_\bs_\bt_\bo_\br_\by and _\bf_\bc builtins
533 to manipulate the history  list.   The  value  of  $_\bH_\bI_\bS_\bT_\bF_\bI_\bL_\bE
534 specifes  the  file where Bash writes the command history on
535 exit and reads it on startup.  $_\bH_\bI_\bS_\bT_\bS_\bI_\bZ_\bE is  used  to  limit
536 the  number  of commands saved in the history.  $_\bH_\bI_\bS_\bT_\bC_\bO_\bN_\bT_\bR_\bO_\bL
537 provides a crude form of control  over  which  commands  are
538 saved  on  the history list: a value of _\bi_\bg_\bn_\bo_\br_\be_\bs_\bp_\ba_\bc_\be means to
539 not save commands which begin  with  a  space;  a  value  of
540 _\bi_\bg_\bn_\bo_\br_\be_\bd_\bu_\bp_\bs  means to not save commands identical to the last
541 command saved.  $HISTCONTROL was named  $history_control  in
542 earlier versions of Bash; the old name is still accepted for
543 backwards compatibility.  The _\bh_\bi_\bs_\bt_\bo_\br_\by command  can  read  or
544 write  files  containing  the  history  list and display the
545 current list contents.  The _\bf_\bc builtin, adopted from POSIX.2
546 and  the  Korn  Shell, allows display and re-execution, with
547 optional editing, of commands from the  history  list.   The
548 readline library offers a set of commands to search the his-
549 tory list for a portion of  the  current  input  line  or  a
550 string  typed  by  the  user.  Finally, the _\bh_\bi_\bs_\bt_\bo_\br_\by library,
551 generally incorporated directly into the  readline  library,
552 implements  a  facility  for  history recall, expansion, and
553 re-execution of previous commands very similar to csh ("bang
554 history", so called because the exclamation point introduces
555 a history substitution):
556 \e9     $ echo a b c d e
557      a b c d e
558      $ !! f g h i
559      echo a b c d e f g h i
560      a b c d e f g h i
561      $ !-2
562      echo a b c d e
563      a b c d e
564      $ echo !-2:1-4
565      echo a b c d
566      a b c d
567 \e9
568 The command history is only saved when the shell is interac-
569 tive, so it is not available for use by shell scripts.
570
571 _\b4._\b5.  _\bN_\be_\bw _\bS_\bh_\be_\bl_\bl _\bV_\ba_\br_\bi_\ba_\bb_\bl_\be_\bs
572
573      There are a number of convenience variables  that  Bash
574 interprets  to  make  life  easier.   These include _\bF_\bI_\bG_\bN_\bO_\bR_\bE,
575 which is a set of filename  suffixes  identifying  files  to
576 exclude   when  completing  filenames;  _\bH_\bO_\bS_\bT_\bT_\bY_\bP_\bE,  which  is
577 automatically  set  to  a  string  describing  the  type  of
578 hardware    on    which   Bash   is   currently   executing;
579 _\bc_\bo_\bm_\bm_\ba_\bn_\bd__\bo_\br_\bi_\be_\bn_\bt_\be_\bd__\bh_\bi_\bs_\bt_\bo_\br_\by, which directs  Bash  to  save  all
580 lines of a multiple-line command such as a _\bw_\bh_\bi_\bl_\be or _\bf_\bo_\br loop
581 in a single history entry,  allowing  easy  re-editing;  and
582 _\bI_\bG_\bN_\bO_\bR_\bE_\bE_\bO_\bF,  whose  value indicates the number of consecutive
583 EOF characters that an interactive shell  will  read  before
584
585
586
587                       October 28, 1994
588
589
590
591
592
593                            - 10 -
594
595
596 exiting - an easy way to keep yourself from being logged out
597 accidentally.  The _\ba_\bu_\bt_\bo__\br_\be_\bs_\bu_\bm_\be variable alters the  way  the
598 shell treats simple command names: if job control is active,
599 and  this  variable  is  set,  single-word  simple  commands
600 without  redirections  cause the shell to first look for and
601 restart a suspended job with that name before starting a new
602 process.
603
604 _\b4._\b6.  _\bB_\br_\ba_\bc_\be _\bE_\bx_\bp_\ba_\bn_\bs_\bi_\bo_\bn
605
606      Since sh offers no convenient way to generate arbitrary
607 strings  that  share  a  common  prefix  or suffix (filename
608 expansion requires that the filenames  exist),  Bash  imple-
609 ments  _\bb_\br_\ba_\bc_\be  _\be_\bx_\bp_\ba_\bn_\bs_\bi_\bo_\bn,  a  capability  picked up from csh.
610 Brace expansion is similar to filename  expansion,  but  the
611 strings  generated need not correspond to existing files.  A
612 brace expression consists of an optional _\bp_\br_\be_\ba_\bm_\bb_\bl_\be,  followed
613 by  a  pair  of braces enclosing a series of comma-separated
614 strings,  and  an  optional  _\bp_\bo_\bs_\bt_\ba_\bm_\bb_\bl_\be.   The  preamble   is
615 prepended  to each string within the braces, and the postam-
616 ble is then appended to each resulting string:
617 \e9     $ echo a{d,c,b}e
618      ade ace abe
619 \e9
620 As this example demonstrates, the results of brace expansion
621 are not sorted, as they are by filename expansion.
622
623 _\b4._\b7.  _\bP_\br_\bo_\bc_\be_\bs_\bs _\bS_\bu_\bb_\bs_\bt_\bi_\bt_\bu_\bt_\bi_\bo_\bn
624
625      On systems that can support it, Bash provides a  facil-
626 ity  known as _\bp_\br_\bo_\bc_\be_\bs_\bs _\bs_\bu_\bb_\bs_\bt_\bi_\bt_\bu_\bt_\bi_\bo_\bn.  Process substitution is
627 similar to command substitution in  that  its  specification
628 includes  a  command to execute, but the shell does not col-
629 lect the command's output and insert  it  into  the  command
630 line.   Rather,  Bash  opens a pipe to the command, which is
631 run in the background.  The shell uses named  pipes  (FIFOs)
632 or  the  /_\bd_\be_\bv/_\bf_\bd  method  of naming open files to expand the
633 process substitution to a filename  which  connects  to  the
634 pipe  when  opened.  This filename becomes the result of the
635 expansion.  Process substitution can be used to compare  the
636 outputs  of two different versions of an application as part
637 of a regression test:
638 \e9     $ cmp <(old_prog) <(new_prog)
639 \e9
640 _\b4._\b8.  _\bP_\br_\bo_\bm_\bp_\bt _\bC_\bu_\bs_\bt_\bo_\bm_\bi_\bz_\ba_\bt_\bi_\bo_\bn
641
642      One of the more popular interactive features that  Bash
643 provides  is the ability to customize the prompt.  Both $_\bP_\bS_\b1
644 and $_\bP_\bS_\b2, the primary and secondary  prompts,  are  expanded
645 before being displayed.  Parameter and variable expansion is
646 performed when the prompt string is expanded, so  any  shell
647 variable  can  be  put  into the prompt (e.g., $_\bS_\bH_\bL_\bV_\bL, which
648
649
650
651                       October 28, 1994
652
653
654
655
656
657                            - 11 -
658
659
660 indicates how deeply the current  shell  is  nested).   Bash
661 specially  interprets  characters  in the prompt string pre-
662 ceded by a backslash.  Some of these backslash  escapes  are
663 replaced  with the current time, the date, the current work-
664 ing directory, the username, and the command number or  his-
665 tory  number  of the command being entered.  There is even a
666 backslash escape to cause the shell  to  change  its  prompt
667 when running as root after an _\bs_\bu.  Before printing each pri-
668 mary prompt, Bash expands the variable $_\bP_\bR_\bO_\bM_\bP_\bT__\bC_\bO_\bM_\bM_\bA_\bN_\bD  and,
669 if it has a value, executes the expanded value as a command,
670 allowing additional prompt customization.  For example, this
671 assignment  causes  the  current user, the current host, the
672 time, the last component of the current  working  directory,
673 the  level  of  shell nesting, and the history number of the
674 current command to be embedded into the primary prompt:
675 \e9     $ PS1='\u@\h [\t] \W($SHLVL:\!)\$ '
676      chet@odin [21:03:44] documentation(2:636)$ cd ..
677      chet@odin [21:03:54] src(2:637)$
678 \e9
679 The string being assigned is surrounded by single quotes  so
680 that  if it is exported, the value of $_\bS_\bH_\bL_\bV_\bL will be updated
681 by a child shell:
682 \e9     chet@odin [21:17:35] src(2:638)$ export PS1
683      chet@odin [21:17:40] src(2:639)$ bash
684      chet@odin [21:17:46] src(3:696)$
685 \e9
686 The \$ escape is displayed as "$" when running as  a  normal
687 user, but as "#" when running as root.
688
689 _\b4._\b9.  _\bF_\bi_\bl_\be _\bS_\by_\bs_\bt_\be_\bm _\bV_\bi_\be_\bw_\bs
690
691      Since Berkeley introduced symbolic links  in  4.2  BSD,
692 one of their most annoying properties has been the "warping"
693 to a completely different area of the file system when using
694 _\bc_\bd,  and  the  resultant  non-intuitive behavior of "cd ..".
695 The UNIX kernel treats symbolic links _\bp_\bh_\by_\bs_\bi_\bc_\ba_\bl_\bl_\by.  When  the
696 kernel is translating a pathname in which one component is a
697 symbolic link, it replaces all or part of the pathname while
698 processing  the  link.  If the contents of the symbolic link
699 begin  with  a  slash,  the  kernel  replaces  the  pathname
700 entirely; if not, the link contents replace the current com-
701 ponent.  In either case, the symbolic link is  visible.   If
702 the  link value is an absolute pathname, the user finds him-
703 self in a completely different part of the file system.
704
705      Bash provides a _\bl_\bo_\bg_\bi_\bc_\ba_\bl view of the  file  system.   In
706 this default mode, command and filename completion and buil-
707 tin commands such as _\bc_\bd and _\bp_\bu_\bs_\bh_\bd which change  the  current
708 working  directory transparently follow symbolic links as if
709 they were directories.  The $_\bP_\bW_\bD variable, which  holds  the
710 shell's  idea  of  the current working directory, depends on
711 the path  used  to  reach  the  directory  rather  than  its
712
713
714
715                       October 28, 1994
716
717
718
719
720
721                            - 12 -
722
723
724 physical  location  in the local file system hierarchy.  For
725 example:
726 \e9     $ cd /usr/local/bin
727      $ echo $PWD
728      /usr/local/bin
729      $ pwd
730      /usr/local/bin
731      $ /bin/pwd
732      /net/share/sun4/local/bin
733      $ cd ..
734      $ pwd
735      /usr/local
736      $ /bin/pwd
737      /net/share/sun4/local
738      $ cd ..
739      $ pwd
740      /usr
741      $ /bin/pwd
742      /usr
743 \e9
744 One problem with this, of course, arises when programs  that
745 do  not  understand  the  shell's logical notion of the file
746 system interpret ".." differently.  This  generally  happens
747 when Bash completes filenames containing ".." according to a
748 logical hierarchy which does not correspond to their  physi-
749 cal  location.  For  users  who  find  this  troublesome,  a
750 corresponding _\bp_\bh_\by_\bs_\bi_\bc_\ba_\bl view of the file system is available:
751 \e9     $ cd /usr/local/bin
752      $ pwd
753      /usr/local/bin
754      $ set -o physical
755      $ pwd
756      /net/share/sun4/local/bin
757 \e9
758 _\b4._\b1_\b0.  _\bI_\bn_\bt_\be_\br_\bn_\ba_\bt_\bi_\bo_\bn_\ba_\bl_\bi_\bz_\ba_\bt_\bi_\bo_\bn
759
760      One of the most  significant  improvements  in  version
761 1.13  of  Bash  was  the  change to "eight-bit cleanliness".
762 Previous versions used the eighth bit of characters to  mark
763 whether  or not they were quoted when performing word expan-
764 sions.  While this did not affect  the  majority  of  users,
765 most  of  whom  used  only  seven-bit ASCII characters, some
766 found it  confining.   Beginning  with  version  1.13,  Bash
767 implemented a different quoting mechanism that did not alter
768 the eighth bit of characters.  This allowed Bash to  manipu-
769 late  files  with  "odd"  characters in their names, but did
770 nothing to help users enter those  names,  so  version  1.13
771 introduced  changes to readline that made it eight-bit clean
772 as well.  Options exist that force  readline  to  attach  no
773 special  significance  to characters with the eighth bit set
774 (the default behavior is  to  convert  these  characters  to
775 meta-prefixed  key sequences) and to output these characters
776
777
778
779                       October 28, 1994
780
781
782
783
784
785                            - 13 -
786
787
788 without  conversion  to  meta-prefixed   sequences.    These
789 changes, along with the expansion of keymaps to a full eight
790 bits, enable readline to work with most of the ISO-8859 fam-
791 ily of character sets, used by many European countries.
792
793 _\b4._\b1_\b1.  _\bP_\bO_\bS_\bI_\bX _\bM_\bo_\bd_\be
794
795      Although Bash is intended  to  be  POSIX.2  conformant,
796 there  are areas in which the default behavior is not compa-
797 tible with the standard.  For users who wish to operate in a
798 strict  POSIX.2  environment,  Bash implements a _\bP_\bO_\bS_\bI_\bX _\bm_\bo_\bd_\be.
799 When this mode is active, Bash modifies its  default  opera-
800 tion  where  it  differs from POSIX.2 to match the standard.
801 POSIX mode is entered when Bash is started with  the  -_\bp_\bo_\bs_\bi_\bx
802 option.   This feature is also available as an option to the
803 set builtin, set -o posix.  For compatibility with other GNU
804 software  that  attempts  to be POSIX.2 compliant, Bash also
805 enters POSIX mode if the variable  $_\bP_\bO_\bS_\bI_\bX_\bL_\bY__\bC_\bO_\bR_\bR_\bE_\bC_\bT  is  set
806 when  Bash  is started or assigned a value during execution.
807 $_\bP_\bO_\bS_\bI_\bX__\bP_\bE_\bD_\bA_\bN_\bT_\bI_\bC is accepted as well, to be  compatible  with
808 some  older  GNU  utilities.   When Bash is started in POSIX
809 mode, for example, it sources the file named by the value of
810 $_\bE_\bN_\bV  rather  than  the "normal" startup files, and does not
811 allow reserved words to be aliased.
812
813 _\b5.  _\bN_\be_\bw _\bF_\be_\ba_\bt_\bu_\br_\be_\bs _\ba_\bn_\bd _\bF_\bu_\bt_\bu_\br_\be _\bP_\bl_\ba_\bn_\bs
814
815      There are several features introduced  in  the  current
816 version of Bash, version 1.14, and a number under considera-
817 tion for future releases.  This section will briefly  detail
818 the  new  features  in  version  1.14  and  describe several
819 features that may appear in later versions.
820
821 _\b5._\b1.  _\bN_\be_\bw _\bF_\be_\ba_\bt_\bu_\br_\be_\bs _\bi_\bn _\bB_\ba_\bs_\bh-_\b1._\b1_\b4
822
823      The new features available in Bash-1.14 answer  several
824 of the most common requests for enhancements.  Most notably,
825 there is a mechanism  for  including  non-visible  character
826 sequences  in  prompts, such as those which cause a terminal
827 to print characters in different colors or in standout mode.
828 There  was  nothing preventing the use of these sequences in
829 earlier  versions,  but  the  readline  redisplay  algorithm
830 assumed  each  character  occupied physical screen space and
831 would wrap lines prematurely.
832
833      Readline has a few new variables, several new  bindable
834 commands,  and  some additional emacs mode default key bind-
835 ings.  A new history search mode has  been  implemented:  in
836 this mode, readline searches the history for lines beginning
837 with the characters between the  beginning  of  the  current
838 line  and  the  cursor.   The  existing readline incremental
839 search commands no longer match identical  lines  more  than
840 once.   Filename  completion now expands variables in direc-
841 tory names.  The history expansion facilities are now nearly
842
843
844
845                       October 28, 1994
846
847
848
849
850
851                            - 14 -
852
853
854 completely csh-compatible: missing modifiers have been added
855 and history substitution has been extended.
856
857      Several of the features described earlier, such as  _\bs_\be_\bt
858 -_\bo  _\bp_\bo_\bs_\bi_\bx  and  $_\bP_\bO_\bS_\bI_\bX__\bP_\bE_\bD_\bA_\bN_\bT_\bI_\bC,  are  new  in version 1.14.
859 There is a new shell variable, _\bO_\bS_\bT_\bY_\bP_\bE, to which Bash assigns
860 a  value that identifies the version of UNIX it's running on
861 (great for putting architecture-specific binary  directories
862 into the $PATH).  Two variables have been renamed: $_\bH_\bI_\bS_\bT_\bC_\bO_\bN_\b-
863 _\bT_\bR_\bO_\bL  replaces  $_\bh_\bi_\bs_\bt_\bo_\br_\by__\bc_\bo_\bn_\bt_\br_\bo_\bl,  and  $_\bH_\bO_\bS_\bT_\bF_\bI_\bL_\bE   replaces
864 $_\bh_\bo_\bs_\bt_\bn_\ba_\bm_\be__\bc_\bo_\bm_\bp_\bl_\be_\bt_\bi_\bo_\bn__\bf_\bi_\bl_\be.  In both cases, the old names are
865 accepted for backwards compatibility.  The ksh  _\bs_\be_\bl_\be_\bc_\bt  con-
866 struct,  which  allows  the  generation of simple menus, has
867 been implemented.   New  capabilities  have  been  added  to
868 existing  variables:  $_\ba_\bu_\bt_\bo__\br_\be_\bs_\bu_\bm_\be  can  now  take values of
869 _\be_\bx_\ba_\bc_\bt or _\bs_\bu_\bb_\bs_\bt_\br_\bi_\bn_\bg, and $_\bH_\bI_\bS_\bT_\bC_\bO_\bN_\bT_\bR_\bO_\bL understands  the  value
870 _\bi_\bg_\bn_\bo_\br_\be_\bb_\bo_\bt_\bh,  which  combines  the  two previously acceptable
871 values.  The _\bd_\bi_\br_\bs builtin has acquired options to print  out
872 specific members of the directory stack.  The $_\bn_\bo_\bl_\bi_\bn_\bk_\bs vari-
873 able, which forces a physical view of the file  system,  has
874 been  superseded  by  the  -_\bP  option  to  the  _\bs_\be_\bt  builtin
875 (equivalent to set -o physical); the  variable  is  retained
876 for  backwards  compatibility.  The version string contained
877 in $_\bB_\bA_\bS_\bH__\bV_\bE_\bR_\bS_\bI_\bO_\bN now includes an  indication  of  the  patch
878 level  as  well  as  the  "build version".  Some little-used
879 features have been removed:  the _\bb_\by_\be synonym  for  _\be_\bx_\bi_\bt  and
880 the  $_\bN_\bO__\bP_\bR_\bO_\bM_\bP_\bT__\bV_\bA_\bR_\bS  variable  are  gone.   There is now an
881 organized test suite that can be run as  a  regression  test
882 when building a new version of Bash.
883
884      The documentation has been thoroughly overhauled: there
885 is  a  new  manual page on the readline library and the _\bi_\bn_\bf_\bo
886 file has been updated to reflect the  current  version.   As
887 always,  as  many bugs as possible have been fixed, although
888 some surely remain.
889
890 _\b5._\b2.  _\bO_\bt_\bh_\be_\br _\bF_\be_\ba_\bt_\bu_\br_\be_\bs
891
892      There are a few features that  I  hope  to  include  in
893 later Bash releases.  Some are based on work already done in
894 other shells.
895
896      In addition to simple variables, a  future  release  of
897 Bash  will  include  one-dimensional  arrays,  using the ksh
898 implementation of arrays as a model.  Additions to  the  ksh
899 syntax,  such  as  _\bv_\ba_\br_\bn_\ba_\bm_\be=( ... ) to assign a list of words
900 directly to an array and a mechanism to allow the _\br_\be_\ba_\bd buil-
901 tin  to  read a list of values directly into an array, would
902 be desirable.  Given those extensions, the ksh _\bs_\be_\bt -_\bA syntax
903 may not be worth supporting (the -_\bA option assigns a list of
904 values to an array, but is a rather peculiar special case).
905
906      Some shells include a means of _\bp_\br_\bo_\bg_\br_\ba_\bm_\bm_\ba_\bb_\bl_\be  word  com-
907 pletion, where the user specifies on a per-command basis how
908
909
910
911                       October 28, 1994
912
913
914
915
916
917                            - 15 -
918
919
920 the arguments of the command are to be treated when  comple-
921 tion  is  attempted:  as  filenames,  hostnames,  executable
922 files, and so on.  The other aspects  of  the  current  Bash
923 implementation  could  remain as-is; the existing heuristics
924 would still be valid.  Only when completing the arguments to
925 a  simple  command  would  the programmable completion be in
926 effect.
927
928      It would also be nice to give  the  user  finer-grained
929 control over which commands are saved onto the history list.
930 One proposal is for a variable,  tentatively  named  _\bH_\bI_\bS_\bT_\bI_\bG_\b-
931 _\bN_\bO_\bR_\bE,  which  would  contain  a colon-separated list of com-
932 mands.  Lines beginning with these commands, after the  res-
933 trictions  of  $_\bH_\bI_\bS_\bT_\bC_\bO_\bN_\bT_\bR_\bO_\bL  have been applied, would not be
934 placed onto the history list.   The  shell  pattern-matching
935 capabilities  could  also  be  available when specifying the
936 contents of $_\bH_\bI_\bS_\bT_\bI_\bG_\bN_\bO_\bR_\bE.
937
938      One thing that newer shells such as _\bw_\bk_\bs_\bh (also known as
939 _\bd_\bt_\bk_\bs_\bh)  provide is a command to dynamically load code imple-
940 menting additional builtin commands into  a  running  shell.
941 This new builtin would take an object file or shared library
942 implementing the "body" of the  builtin  (_\bx_\bx_\bx__\bb_\bu_\bi_\bl_\bt_\bi_\bn()  for
943 those familiar with Bash internals) and a structure contain-
944 ing the name of the new command, the function to  call  when
945 the new builtin is invoked (presumably defined in the shared
946 object specified as an argument), and the  documentation  to
947 be  printed  by  the  _\bh_\be_\bl_\bp  command (possibly present in the
948 shared object as well).  It  would  manage  the  details  of
949 extending the internal table of builtins.
950
951      A few other builtins would also be desirable:  two  are
952 the POSIX.2 _\bg_\be_\bt_\bc_\bo_\bn_\bf command, which prints the values of sys-
953 tem configuration variables defined by POSIX.2, and a _\bd_\bi_\bs_\bo_\bw_\bn
954 builtin,  which  causes  a  shell  running  with job control
955 active to "forget about" one or more background jobs in  its
956 internal  jobs  table.   Using  _\bg_\be_\bt_\bc_\bo_\bn_\bf, for example, a user
957 could retrieve a value for $_\bP_\bA_\bT_\bH guaranteed to find  all  of
958 the POSIX standard utilities, or find out how long filenames
959 may be in the file system containing a specified directory.
960
961      There are no implementation timetables for any of these
962 features,  nor are there concrete plans to include them.  If
963 anyone has comments on these proposals, feel free to send me
964 electronic mail.
965
966 _\b6.  _\bR_\be_\bf_\bl_\be_\bc_\bt_\bi_\bo_\bn_\bs _\ba_\bn_\bd _\bL_\be_\bs_\bs_\bo_\bn_\bs _\bL_\be_\ba_\br_\bn_\be_\bd
967
968      The lesson that has been  repeated  most  often  during
969 Bash  development  is  that  there  are  dark corners in the
970 Bourne shell, and people use all of them.  In  the  original
971 description of the Bourne shell, quoting and the shell gram-
972 mar are both poorly  specified  and  incomplete;  subsequent
973 descriptions have not helped much.  The grammar presented in
974
975
976
977                       October 28, 1994
978
979
980
981
982
983                            - 16 -
984
985
986 Bourne's paper describing the  shell  distributed  with  the
987 Seventh  Edition  of  UNIX|\b-  is  so far off that it does not
988 allow the command who|wc.  In fact, as Tom Duff states:
989
990      Nobody really knows what the Bourne shell's  gram-
991      mar  is.   Even  examination of the source code is
992      little help.|\b=
993
994 The POSIX.2 standard includes  a  _\by_\ba_\bc_\bc  grammar  that  comes
995 close  to  capturing  the  Bourne  shell's  behavior, but it
996 disallows some constructs which sh accepts without complaint
997 -  and there are scripts out there that use them.  It took a
998 few versions and several bug reports before Bash implemented
999 sh-compatible  quoting,  and there are still some "legal" sh
1000 constructs which Bash flags as syntax errors.   Complete  sh
1001 compatibility is a tough nut.
1002
1003      The shell is bigger  and  slower  than  I  would  like,
1004 though the current version is substantially faster than pre-
1005 viously.  The readline library  could  stand  a  substantial
1006 rewrite.   A  hand-written  parser  to  replace  the current
1007 _\by_\ba_\bc_\bc-generated one would probably result in a  speedup,  and
1008 would solve one glaring problem:  the shell could parse com-
1009 mands in "$(...)" constructs as  they  are  entered,  rather
1010 than reporting errors when the construct is expanded.
1011
1012      As always, there is some chaff to go  with  the  wheat.
1013 Areas  of  duplicated  functionality  need to be cleaned up.
1014 There are several cases where Bash treats  a  variable  spe-
1015 cially   to   enable  functionality  available  another  way
1016 ($notify vs.  set -o notify and $nolinks vs. set  -o  physi-
1017 cal,  for  instance);  the special treatment of the variable
1018 name should probably be removed.  A few  more  things  could
1019 stand    removal;    the    $_\ba_\bl_\bl_\bo_\bw__\bn_\bu_\bl_\bl__\bg_\bl_\bo_\bb__\be_\bx_\bp_\ba_\bn_\bs_\bi_\bo_\bn   and
1020 $_\bg_\bl_\bo_\bb__\bd_\bo_\bt__\bf_\bi_\bl_\be_\bn_\ba_\bm_\be_\bs variables are of particularly  question-
1021 able  value.   The  $[...]  arithmetic  evaluation syntax is
1022 redundant now that the POSIX-mandated $((...)) construct has
1023 been implemented, and could be deleted.  It would be nice if
1024 the text output by the _\bh_\be_\bl_\bp builtin  were  external  to  the
1025 shell rather than compiled into it.  The behavior enabled by
1026 $_\bc_\bo_\bm_\bm_\ba_\bn_\bd__\bo_\br_\bi_\be_\bn_\bt_\be_\bd__\bh_\bi_\bs_\bt_\bo_\br_\by, which causes the shell to attempt
1027 to  save  all lines of a multi-line command in a single his-
1028 tory entry, should be made  the  default  and  the  variable
1029 removed.
1030
1031
1032 _________________________
1033 |\b-S. R. Bourne, "UNIX  Time-Sharing  System:   The  UNIX
1034 Shell",  _\bB_\be_\bl_\bl  _\bS_\by_\bs_\bt_\be_\bm  _\bT_\be_\bc_\bh_\bn_\bi_\bc_\ba_\bl  _\bJ_\bo_\bu_\br_\bn_\ba_\bl, 57(6), July-
1035 August, 1978, pp. 1971-1990.
1036 |\b=Tom Duff, "Rc - A Shell for Plan 9 and UNIX  systems",
1037 _\bP_\br_\bo_\bc. _\bo_\bf _\bt_\bh_\be _\bS_\bu_\bm_\bm_\be_\br _\b1_\b9_\b9_\b0 _\bE_\bU_\bU_\bG _\bC_\bo_\bn_\bf_\be_\br_\be_\bn_\bc_\be, London, July,
1038 1990, pp. 21-33.
1039
1040
1041
1042
1043                       October 28, 1994
1044
1045
1046
1047
1048
1049                            - 17 -
1050
1051
1052 _\b7.  _\bA_\bv_\ba_\bi_\bl_\ba_\bb_\bi_\bl_\bi_\bt_\by
1053
1054      As with all other GNU software, Bash is  available  for
1055 anonymous  FTP  from _\bp_\br_\be_\bp._\ba_\bi._\bm_\bi_\bt._\be_\bd_\bu:/_\bp_\bu_\bb/_\bg_\bn_\bu and from other
1056 GNU software mirror sites.  The current version is in  _\bb_\ba_\bs_\bh-
1057 _\b1._\b1_\b4._\b1._\bt_\ba_\br._\bg_\bz  in  that  directory.   Use _\ba_\br_\bc_\bh_\bi_\be to find the
1058 nearest archive site.  The latest version is  always  avail-
1059 able  for FTP from _\bb_\ba_\bs_\bh._\bC_\bW_\bR_\bU._\bE_\bd_\bu:/_\bp_\bu_\bb/_\bd_\bi_\bs_\bt.  Bash documenta-
1060 tion is available for FTP from _\bb_\ba_\bs_\bh._\bC_\bW_\bR_\bU._\bE_\bd_\bu:/_\bp_\bu_\bb/_\bb_\ba_\bs_\bh.
1061
1062      The Free Software Foundation sells  tapes  and  CD-ROMs
1063 containing Bash; send electronic mail to gnu@prep.ai.mit.edu
1064 or call +1-617-876-3296 for more information.
1065
1066      Bash is  also  distributed  with  several  versions  of
1067 UNIX-compatible  systems.   It  is  included  as /bin/sh and
1068 /bin/bash on several Linux  distributions  (more  about  the
1069 difference  in  a  moment),  and  as contributed software in
1070 BSDI's BSD/386* and FreeBSD.
1071
1072      The Linux distribution deserves special mention.  There
1073 are two configurations included in the standard Bash distri-
1074 bution: a "normal" configuration, in which all of the  stan-
1075 dard  features  are included, and a "minimal" configuration,
1076 which omits job control, aliases, history and  command  line
1077 editing,  the  directory  stack and _\bp_\bu_\bs_\bh_\bd/_\bp_\bo_\bp_\bd/_\bd_\bi_\br_\bs, process
1078 substitution, prompt string special character decoding,  and
1079 the  _\bs_\be_\bl_\be_\bc_\bt  construct.  This minimal version is designed to
1080 be a drop-in replacement for the traditional  UNIX  /bin/sh,
1081 and is included as the Linux /bin/sh in several packagings.
1082
1083 _\b8.  _\bC_\bo_\bn_\bc_\bl_\bu_\bs_\bi_\bo_\bn
1084
1085      Bash is a worthy successor to sh.  It  is  sufficiently
1086 portable to run on nearly every version of UNIX from 4.3 BSD
1087 to SVR4.2, and several UNIX workalikes.  It is robust enough
1088 to  replace  sh  on most of those systems, and provides more
1089 functionality.  It has several thousand regular  users,  and
1090 their  feedback has helped to make it as good as it is today
1091 - a testament to the benefits of free software.
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102 _________________________
1103 *BSD/386 is a trademark of  Berkeley  Software  Design,
1104 Inc.
1105
1106
1107
1108
1109                       October 28, 1994
1110
1111