⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 article.txt

📁 android-w.song.android.widget
💻 TXT
📖 第 1 页 / 共 4 页
字号:
     a b c d e     $ !! f g h i     echo a b c d e f g h i     a b c d e f g h i     $ !-2     echo a b c d e     a b c d e     $ echo !-2:1-4     echo a b c d     a b c d9The command history is only saved when the shell is interac-tive, so it is not available for use by shell scripts._4._5.  _N_e_w _S_h_e_l_l _V_a_r_i_a_b_l_e_s     There are a number of convenience variables  that  Bashinterprets  to  make  life  easier.   These include _F_I_G_N_O_R_E,which is a set of filename  suffixes  identifying  files  toexclude   when  completing  filenames;  _H_O_S_T_T_Y_P_E,  which  isautomatically  set  to  a  string  describing  the  type  ofhardware    on    which   Bash   is   currently   executing;_c_o_m_m_a_n_d__o_r_i_e_n_t_e_d__h_i_s_t_o_r_y, which directs  Bash  to  save  alllines of a multiple-line command such as a _w_h_i_l_e or _f_o_r loopin a single history entry,  allowing  easy  re-editing;  and_I_G_N_O_R_E_E_O_F,  whose  value indicates the number of consecutiveEOF characters that an interactive shell  will  read  before                      October 28, 1994                           - 10 -exiting - an easy way to keep yourself from being logged outaccidentally.  The _a_u_t_o__r_e_s_u_m_e variable alters the  way  theshell treats simple command names: if job control is active,and  this  variable  is  set,  single-word  simple  commandswithout  redirections  cause the shell to first look for andrestart a suspended job with that name before starting a newprocess._4._6.  _B_r_a_c_e _E_x_p_a_n_s_i_o_n     Since sh offers no convenient way to generate arbitrarystrings  that  share  a  common  prefix  or suffix (filenameexpansion requires that the filenames  exist),  Bash  imple-ments  _b_r_a_c_e  _e_x_p_a_n_s_i_o_n,  a  capability  picked up from csh.Brace expansion is similar to filename  expansion,  but  thestrings  generated need not correspond to existing files.  Abrace expression consists of an optional _p_r_e_a_m_b_l_e,  followedby  a  pair  of braces enclosing a series of comma-separatedstrings,  and  an  optional  _p_o_s_t_a_m_b_l_e.   The  preamble   isprepended  to each string within the braces, and the postam-ble is then appended to each resulting string:9     $ echo a{d,c,b}e     ade ace abe9As this example demonstrates, the results of brace expansionare not sorted, as they are by filename expansion._4._7.  _P_r_o_c_e_s_s _S_u_b_s_t_i_t_u_t_i_o_n     On systems that can support it, Bash provides a  facil-ity  known as _p_r_o_c_e_s_s _s_u_b_s_t_i_t_u_t_i_o_n.  Process substitution issimilar to command substitution in  that  its  specificationincludes  a  command to execute, but the shell does not col-lect the command's output and insert  it  into  the  commandline.   Rather,  Bash  opens a pipe to the command, which isrun in the background.  The shell uses named  pipes  (FIFOs)or  the  /_d_e_v/_f_d  method  of naming open files to expand theprocess substitution to a filename  which  connects  to  thepipe  when  opened.  This filename becomes the result of theexpansion.  Process substitution can be used to compare  theoutputs  of two different versions of an application as partof a regression test:9     $ cmp <(old_prog) <(new_prog)9_4._8.  _P_r_o_m_p_t _C_u_s_t_o_m_i_z_a_t_i_o_n     One of the more popular interactive features that  Bashprovides  is the ability to customize the prompt.  Both $_P_S_1and $_P_S_2, the primary and secondary  prompts,  are  expandedbefore being displayed.  Parameter and variable expansion isperformed when the prompt string is expanded, so  any  shellvariable  can  be  put  into the prompt (e.g., $_S_H_L_V_L, which                      October 28, 1994                           - 11 -indicates how deeply the current  shell  is  nested).   Bashspecially  interprets  characters  in the prompt string pre-ceded by a backslash.  Some of these backslash  escapes  arereplaced  with the current time, the date, the current work-ing directory, the username, and the command number or  his-tory  number  of the command being entered.  There is even abackslash escape to cause the shell  to  change  its  promptwhen running as root after an _s_u.  Before printing each pri-mary prompt, Bash expands the variable $_P_R_O_M_P_T__C_O_M_M_A_N_D  and,if it has a value, executes the expanded value as a command,allowing additional prompt customization.  For example, thisassignment  causes  the  current user, the current host, thetime, the last component of the current  working  directory,the  level  of  shell nesting, and the history number of thecurrent command to be embedded into the primary prompt:9     $ PS1='\u@\h [\t] \W($SHLVL:\!)\$ '     chet@odin [21:03:44] documentation(2:636)$ cd ..     chet@odin [21:03:54] src(2:637)$9The string being assigned is surrounded by single quotes  sothat  if it is exported, the value of $_S_H_L_V_L will be updatedby a child shell:9     chet@odin [21:17:35] src(2:638)$ export PS1     chet@odin [21:17:40] src(2:639)$ bash     chet@odin [21:17:46] src(3:696)$9The \$ escape is displayed as "$" when running as  a  normaluser, but as "#" when running as root._4._9.  _F_i_l_e _S_y_s_t_e_m _V_i_e_w_s     Since Berkeley introduced symbolic links  in  4.2  BSD,one of their most annoying properties has been the "warping"to a completely different area of the file system when using_c_d,  and  the  resultant  non-intuitive behavior of "cd ..".The UNIX kernel treats symbolic links _p_h_y_s_i_c_a_l_l_y.  When  thekernel is translating a pathname in which one component is asymbolic link, it replaces all or part of the pathname whileprocessing  the  link.  If the contents of the symbolic linkbegin  with  a  slash,  the  kernel  replaces  the  pathnameentirely; if not, the link contents replace the current com-ponent.  In either case, the symbolic link is  visible.   Ifthe  link value is an absolute pathname, the user finds him-self in a completely different part of the file system.     Bash provides a _l_o_g_i_c_a_l view of the  file  system.   Inthis default mode, command and filename completion and buil-tin commands such as _c_d and _p_u_s_h_d which change  the  currentworking  directory transparently follow symbolic links as ifthey were directories.  The $_P_W_D variable, which  holds  theshell's  idea  of  the current working directory, depends onthe path  used  to  reach  the  directory  rather  than  its                      October 28, 1994                           - 12 -physical  location  in the local file system hierarchy.  Forexample:9     $ cd /usr/local/bin     $ echo $PWD     /usr/local/bin     $ pwd     /usr/local/bin     $ /bin/pwd     /net/share/sun4/local/bin     $ cd ..     $ pwd     /usr/local     $ /bin/pwd     /net/share/sun4/local     $ cd ..     $ pwd     /usr     $ /bin/pwd     /usr9One problem with this, of course, arises when programs  thatdo  not  understand  the  shell's logical notion of the filesystem interpret ".." differently.  This  generally  happenswhen Bash completes filenames containing ".." according to alogical hierarchy which does not correspond to their  physi-cal  location.  For  users  who  find  this  troublesome,  acorresponding _p_h_y_s_i_c_a_l view of the file system is available:9     $ cd /usr/local/bin     $ pwd     /usr/local/bin     $ set -o physical     $ pwd     /net/share/sun4/local/bin9_4._1_0.  _I_n_t_e_r_n_a_t_i_o_n_a_l_i_z_a_t_i_o_n     One of the most  significant  improvements  in  version1.13  of  Bash  was  the  change to "eight-bit cleanliness".Previous versions used the eighth bit of characters to  markwhether  or not they were quoted when performing word expan-sions.  While this did not affect  the  majority  of  users,most  of  whom  used  only  seven-bit ASCII characters, somefound it  confining.   Beginning  with  version  1.13,  Bashimplemented a different quoting mechanism that did not alterthe eighth bit of characters.  This allowed Bash to  manipu-late  files  with  "odd"  characters in their names, but didnothing to help users enter those  names,  so  version  1.13introduced  changes to readline that made it eight-bit cleanas well.  Options exist that force  readline  to  attach  nospecial  significance  to characters with the eighth bit set(the default behavior is  to  convert  these  characters  tometa-prefixed  key sequences) and to output these characters                      October 28, 1994                           - 13 -without  conversion  to  meta-prefixed   sequences.    Thesechanges, along with the expansion of keymaps to a full eightbits, enable readline to work with most of the ISO-8859 fam-ily of character sets, used by many European countries._4._1_1.  _P_O_S_I_X _M_o_d_e     Although Bash is intended  to  be  POSIX.2  conformant,there  are areas in which the default behavior is not compa-tible with the standard.  For users who wish to operate in astrict  POSIX.2  environment,  Bash implements a _P_O_S_I_X _m_o_d_e.When this mode is active, Bash modifies its  default  opera-tion  where  it  differs from POSIX.2 to match the standard.POSIX mode is entered when Bash is started with  the  -_p_o_s_i_xoption.   This feature is also available as an option to theset builtin, set -o posix.  For compatibility with other GNUsoftware  that  attempts  to be POSIX.2 compliant, Bash alsoenters POSIX mode if the variable  $_P_O_S_I_X_L_Y__C_O_R_R_E_C_T  is  setwhen  Bash  is started or assigned a value during execution.$_P_O_S_I_X__P_E_D_A_N_T_I_C is accepted as well, to be  compatible  withsome  older  GNU  utilities.   When Bash is started in POSIXmode, for example, it sources the file named by the value of$_E_N_V  rather  than  the "normal" startup files, and does notallow reserved words to be aliased._5.  _N_e_w _F_e_a_t_u_r_e_s _a_n_d _F_u_t_u_r_e _P_l_a_n_s     There are several features introduced  in  the  currentversion of Bash, version 1.14, and a number under considera-tion for future releases.  This section will briefly  detailthe  new  features  in  version  1.14  and  describe severalfeatures that may appear in later versions._5._1.  _N_e_w _F_e_a_t_u_r_e_s _i_n _B_a_s_h-_1._1_4     The new features available in Bash-1.14 answer  severalof the most common requests for enhancements.  Most notably,there is a mechanism  for  including  non-visible  charactersequences  in  prompts, such as those which cause a terminalto print characters in different colors or in standout mode.There  was  nothing preventing the use of these sequences inearlier  versions,  but  the  readline  redisplay  algorithmassumed  each  character  occupied physical screen space andwould wrap lines prematurely.     Readline has a few new variables, several new  bindablecommands,  and  some additional emacs mode default key bind-

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -