home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / NEXTSTEP / UNIX / Shells / zsh-3.0.5-MIHS / docs / intro.text < prev    next >
Encoding:
Text File  |  1994-06-03  |  126.1 KB  |  3,367 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.                AAnn IInnttrroodduuccttiioonn ttoo tthhee ZZ SShheellll
  11.  
  12.                         _P_a_u_l _F_a_l_s_t_a_d
  13.                        _p_f_@_z_-_c_o_d_e_._c_o_m
  14.                        _B_a_s _d_e _B_a_k_k_e_r
  15.                       _b_a_s_@_p_h_y_s_._u_v_a_._n_l
  16.  
  17.  
  18.  
  19. IInnttrroodduuccttiioonn
  20.  
  21. zzsshh  is a shell designed for interactive use, although it is
  22. also a powerful scripting language.  Many of the useful fea-
  23. tures  of  bash,  ksh,  and tcsh were incorporated into zzsshh;
  24. many original features were added.   This  document  details
  25. some of the unique features of zzsshh.  It assumes basic knowl-
  26. edge of the standard UNIX shells; the intent is  to  show  a
  27. reader  already  familiar with one of the other major shells
  28. what makes zzsshh more useful or more powerful.  This  document
  29. is  not  at  all  comprehensive; read the manual entry for a
  30. description of the  shell  that  is  complete  and  concise,
  31. although somewhat overwhelming and devoid of examples.
  32.  
  33. The text will frequently mention options that you can set to
  34. change the behaviour of zzsshh.  You can set these options with
  35. the command
  36.  
  37. %% sseettoopptt _o_p_t_i_o_n_n_a_m_e
  38.  
  39. and unset them again with
  40.  
  41. %% uunnsseettoopptt _o_p_t_i_o_n_n_a_m_e
  42.  
  43. Case  is  ignored  in  option  names, as are embedded under-
  44. scores.
  45.  
  46. FFiilleennaammee GGeenneerraattiioonn
  47.  
  48. Otherwise known as _g_l_o_b_b_i_n_g, filename  generation  is  quite
  49. extensive in zzsshh.  Of course, it has all the basics:
  50.  
  51. %% llss
  52. MMaakkeeffiillee   ffiillee..pprroo   ffoooo..oo      mmaaiinn..oo     qq..cc        rruunn223344     ssttuuffff
  53. bbaarr..oo      ffoooo        lliinnkk       mmoorreessttuuffff  rruunn112233     rruunn224400     ssuubb
  54. ffiillee..hh     ffoooo..cc      mmaaiinn..hh     ppiippee       rruunn22       rruunn330033
  55. %% llss **..cc
  56. ffoooo..cc  qq..cc
  57. %% llss **..[[ccoo]]
  58. bbaarr..oo   ffoooo..cc   ffoooo..oo   mmaaiinn..oo  qq..cc
  59. %% llss ffoooo..??
  60. ffoooo..cc  ffoooo..oo
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.                              -2-
  71.  
  72.  
  73. %% llss **..[[^^cc]]
  74. bbaarr..oo   ffiillee..hh  ffoooo..oo   mmaaiinn..hh  mmaaiinn..oo
  75. %% llss **..[[^^oohh]]
  76. ffoooo..cc  qq..cc
  77.  
  78. Also,  if  the _E_X_T_E_N_D_E_D_G_L_O_B option is set, some new features
  79. are activated.  For example, the  ^^  character  negates  the
  80. pattern following it:
  81.  
  82. %% sseettoopptt eexxtteennddeeddgglloobb
  83. %% llss --dd ^^**..cc
  84. MMaakkeeffiillee   ffiillee..pprroo   lliinnkk       mmoorreessttuuffff  rruunn22       rruunn330033
  85. bbaarr..oo      ffoooo        mmaaiinn..hh     ppiippee       rruunn223344     ssttuuffff
  86. ffiillee..hh     ffoooo..oo      mmaaiinn..oo     rruunn112233     rruunn224400     ssuubb
  87. %% llss --dd ^^**..**
  88. MMaakkeeffiillee   lliinnkk       ppiippee       rruunn22       rruunn224400     ssttuuffff
  89. ffoooo        mmoorreessttuuffff  rruunn112233     rruunn223344     rruunn330033     ssuubb
  90. %% llss --dd ^^MMaakkeeffiillee
  91. bbaarr..oo      ffoooo        lliinnkk       mmoorreessttuuffff  rruunn112233     rruunn224400     ssuubb
  92. ffiillee..hh     ffoooo..cc      mmaaiinn..hh     ppiippee       rruunn22       rruunn330033
  93. ffiillee..pprroo   ffoooo..oo      mmaaiinn..oo     qq..cc        rruunn223344     ssttuuffff
  94. %% llss --dd **..^^cc
  95. ..rrhhoossttss   bbaarr..oo     ffiillee..hh    ffiillee..pprroo  ffoooo..oo     mmaaiinn..hh    mmaaiinn..oo
  96.  
  97. An expression of the form <<_x-_y>> matches a range of integers:
  98.  
  99. %% llss rruunn<<220000--330000>>
  100. rruunn223344  rruunn224400
  101. %% llss rruunn<<330000--440000>>
  102. rruunn330033
  103. %% llss rruunn<<--220000>>
  104. rruunn112233  rruunn22
  105. %% llss rruunn<<330000-->>
  106. rruunn330033
  107. %% llss rruunn<<>>
  108. rruunn112233  rruunn22    rruunn223344  rruunn224400  rruunn330033
  109.  
  110. The _N_U_M_E_R_I_C_G_L_O_B_S_O_R_T option  will  sort  files  with  numbers
  111. according  to  the number.  This will not work with llss as it
  112. resorts its arguments:
  113.  
  114. %% sseettoopptt nnuummeerriiccgglloobbssoorrtt
  115. %% eecchhoo rruunn<<>>
  116. rruunn22 rruunn112233 rruunn223344 rruunn224400 rruunn330033
  117.  
  118. Grouping is possible:
  119.  
  120. %% llss ((ffoooo||bbaarr))..**
  121. bbaarr..oo  ffoooo..cc  ffoooo..oo
  122. %% llss **..((cc||oo||pprroo))
  123. bbaarr..oo     ffiillee..pprroo  ffoooo..cc     ffoooo..oo     mmaaiinn..oo    qq..cc
  124.  
  125. Also, the string ****// forces a recursive search of  subdirec-
  126. tories:
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.                              -3-
  137.  
  138.  
  139. %% llss --RR
  140. MMaakkeeffiillee   ffiillee..pprroo   ffoooo..oo      mmaaiinn..oo     qq..cc        rruunn223344     ssttuuffff
  141. bbaarr..oo      ffoooo        lliinnkk       mmoorreessttuuffff  rruunn112233     rruunn224400     ssuubb
  142. ffiillee..hh     ffoooo..cc      mmaaiinn..hh     ppiippee       rruunn22       rruunn330033
  143.  
  144. mmoorreessttuuffff::
  145.  
  146. ssttuuffff::
  147. ffiillee  xxxxxx   yyyyyy
  148.  
  149. ssttuuffff//xxxxxx::
  150. ffoooobbaarr
  151.  
  152. ssttuuffff//yyyyyy::
  153. ffrroobbaarr
  154. %% llss ****//**bbaarr
  155. ssttuuffff//xxxxxx//ffoooobbaarr  ssttuuffff//yyyyyy//ffrroobbaarr
  156. %% llss ****//ff**
  157. ffiillee..hh            ffoooo               ffoooo..oo             ssttuuffff//xxxxxx//ffoooobbaarr
  158. ffiillee..pprroo          ffoooo..cc             ssttuuffff//ffiillee        ssttuuffff//yyyyyy//ffrroobbaarr
  159. %% llss **bbaarr**
  160. bbaarr..oo
  161. %% llss ****//**bbaarr**
  162. bbaarr..oo             ssttuuffff//xxxxxx//ffoooobbaarr  ssttuuffff//yyyyyy//ffrroobbaarr
  163. %% llss ssttuuffff//****//**bbaarr**
  164. ssttuuffff//xxxxxx//ffoooobbaarr  ssttuuffff//yyyyyy//ffrroobbaarr
  165.  
  166.  
  167. It  is  possible  to exclude certain files from the patterns
  168. using the ~ character.  A  pattern  of  the  form  **..cc~~bbaarr..cc
  169. lists all files matching **..cc, except for the file bbaarr..cc.
  170.  
  171. %% llss **..cc
  172. ffoooo..cc    ffoooobb..cc    bbaarr..cc
  173. %% llss **..cc~~bbaarr..cc
  174. ffoooo..cc    ffoooobb..cc
  175. %% llss **..cc~~ff**
  176. bbaarr..cc
  177.  
  178.  
  179. One  can  add  a  number  of _q_u_a_l_i_f_i_e_r_s to the end of any of
  180. these patterns, to restrict matches to certain  file  types.
  181. A qualified pattern is of the form
  182.  
  183.      _p_a_t_t_e_r_n((...))
  184.  
  185. with single-character qualifiers inside the parentheses.
  186.  
  187. %% aalliiaass ll==''llss --ddFF''
  188. %% ll **
  189. MMaakkeeffiillee    ffoooo**        mmaaiinn..hh      qq..cc         rruunn224400
  190. bbaarr..oo       ffoooo..cc       mmaaiinn..oo      rruunn112233      rruunn330033
  191. ffiillee..hh      ffoooo..oo       mmoorreessttuuffff//  rruunn22        ssttuuffff//
  192. ffiillee..pprroo    lliinnkk@@       ppiippee        rruunn223344      ssuubb
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.                              -4-
  203.  
  204.  
  205. %% ll **((//))
  206. mmoorreessttuuffff//  ssttuuffff//
  207. %% ll **((@@))
  208. lliinnkk@@
  209. %% ll **((**))
  210. ffoooo**        lliinnkk@@       mmoorreessttuuffff//  ssttuuffff//
  211. %% ll **((xx))
  212. ffoooo**        lliinnkk@@       mmoorreessttuuffff//  ssttuuffff//
  213. %% ll **((XX))
  214. ffoooo**        lliinnkk@@       mmoorreessttuuffff//  ssttuuffff//
  215. %% ll **((RR))
  216. bbaarr..oo       ffoooo**        lliinnkk@@       mmoorreessttuuffff//  rruunn112233      rruunn224400
  217. ffiillee..hh      ffoooo..cc       mmaaiinn..hh      ppiippee        rruunn22        rruunn330033
  218. ffiillee..pprroo    ffoooo..oo       mmaaiinn..oo      qq..cc         rruunn223344      ssttuuffff//
  219.  
  220. Note  that  **((xx))  and  **((**))  both  match  executables.  **((XX))
  221. matches files executable by  others,  as  opposed  to  **((xx)),
  222. which  matches files executable by the owner.  **((RR)) and **((rr))
  223. match readable  files;  **((WW))  and  **((ww)),  which  checks  for
  224. writable  files.   **((WW))  is  especially  important, since it
  225. checks for world-writable files:
  226.  
  227. %% ll **((ww))
  228. bbaarr..oo       ffoooo**        lliinnkk@@       mmoorreessttuuffff//  rruunn112233      rruunn224400
  229. ffiillee..hh      ffoooo..cc       mmaaiinn..hh      ppiippee        rruunn22        rruunn330033
  230. ffiillee..pprroo    ffoooo..oo       mmaaiinn..oo      qq..cc         rruunn223344      ssttuuffff//
  231. %% ll **((WW))
  232. lliinnkk@@   rruunn224400
  233. %% ll --ll lliinnkk rruunn224400
  234. llrrwwxxrrwwxxrrwwxx  11 ppffaallssttaadd       1100 MMaayy 2233 1188::1122 lliinnkk -->> //uussrr//bbiinn//
  235. --rrww--rrww--rrww--  11 ppffaallssttaadd        00 MMaayy 2233 1188::1122 rruunn224400
  236.  
  237. If you want to have all the files of a certain type as  well
  238. as all symbolic links pointing to files of that type, prefix
  239. the qualifier with a --:
  240.  
  241. %% ll **((--//))
  242. lliinnkk@@       mmoorreessttuuffff//  ssttuuffff//
  243.  
  244. You can filter out the symbolic links with the ^^ character:
  245.  
  246. %% ll **((WW^^@@))
  247. rruunn224400
  248. %% ll **((xx))
  249. ffoooo**        lliinnkk@@       mmoorreessttuuffff//  ssttuuffff//
  250. %% ll **((xx^^@@//))
  251. ffoooo**
  252.  
  253. To find all plain files, you can use ..:
  254.  
  255. %% ll **((..))
  256. MMaakkeeffiillee  ffiillee..hh    ffoooo**      ffoooo..oo     mmaaiinn..oo    rruunn112233    rruunn223344    rruunn330033
  257. bbaarr..oo     ffiillee..pprroo  ffoooo..cc     mmaaiinn..hh    qq..cc       rruunn22      rruunn224400    ssuubb
  258. %% ll **((^^..))
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.                              -5-
  269.  
  270.  
  271. lliinnkk@@       mmoorreessttuuffff//  ppiippee        ssttuuffff//
  272. %% ll ss**((..))
  273. ssttuuffff//   ssuubb
  274. %% ll **((pp))
  275. ppiippee
  276. %% ll --ll **((pp))
  277. pprrww--rr----rr----  11 ppffaallssttaadd        00 MMaayy 2233 1188::1122 ppiippee
  278.  
  279. **((UU)) matches all files owned by  you.   To  search  for  all
  280. files not owned by you, use **((^^UU)):
  281.  
  282. %% ll --ll **((^^UU))
  283. --rrww--------------  11 ssuubbbbaarraaoo       2299 MMaayy 2233 1188::1133 ssuubb
  284.  
  285. This searches for setuid files:
  286.  
  287. %% ll --ll **((ss))
  288. --rrwwssrr--xxrr--xx  11 ppffaallssttaadd       1166 MMaayy 2233 1188::1122 ffoooo**
  289.  
  290. This checks for a certain user's files:
  291.  
  292. %% ll --ll **((uu[[ssuubbbbaarraaoo]]))
  293. --rrww--------------  11 ssuubbbbaarraaoo       2299 MMaayy 2233 1188::1133 ssuubb
  294.  
  295.  
  296. SSttaarrttuupp FFiilleess
  297.  
  298. There  are  five  startup  files that zzsshh will read commands
  299. from:
  300.  
  301. $$ZZDDOOTTDDIIRR//..zzsshheennvv
  302. $$ZZDDOOTTDDIIRR//..zzpprrooffiillee
  303. $$ZZDDOOTTDDIIRR//..zzsshhrrcc
  304. $$ZZDDOOTTDDIIRR//..zzllooggiinn
  305. $$ZZDDOOTTDDIIRR//..zzllooggoouutt
  306.  
  307. If ZZDDOOTTDDIIRR is not set, then the value of HHOOMMEE is used;  this
  308. is the usual case.
  309.  
  310. ..zzsshheennvv  is  sourced on all invocations of the shell, unless
  311. the --ff option is set.  It should contain commands to set the
  312. command  search path, plus other important environment vari-
  313. ables.  ..zzsshheennvv should not  contain  commands  that  produce
  314. output or assume the shell is attached to a tty.
  315.  
  316. ..zzsshhrrcc  is sourced in interactive shells.  It should contain
  317. commands to set up aliases, functions,  options,  key  bind-
  318. ings, etc.
  319.  
  320. ..zzllooggiinn  is sourced in login shells.  It should contain com-
  321. mands that should be executed only in login  shells.   ..zzlloo--
  322. ggoouutt  is sourced when login shells exit.  ..zzpprrooffiillee is simi-
  323. lar to ..zzllooggiinn, except that it  is  sourced  before  ..zzsshhrrcc.
  324. ..zzpprrooffiillee  is  meant  as  an  alternative to ..zzllooggiinn for ksh
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.                              -6-
  335.  
  336.  
  337. fans; the two are not intended to be used together, although
  338. this could certainly be done if desired.  ..zzllooggiinn is not the
  339. place for alias definitions, options,  environment  variable
  340. settings,  etc.; as a general rule, it should not change the
  341. shell environment at all.  Rather, it should be used to  set
  342. the  terminal  type  and  run  a series of external commands
  343. (ffoorrttuunnee, mmssggss, etc).
  344.  
  345. SShheellll FFuunnccttiioonnss
  346.  
  347. zzsshh also allows you to create your own commands by  defining
  348. shell functions.  For example:
  349.  
  350. %% yypp (()) {{
  351. >>       yyppmmaattcchh $$11 ppaasssswwdd..bbyynnaammee
  352. >> }}
  353. %% yypp ppffaallssttaadd
  354. ppffaallssttaadd::**::33556644::3355::PPaauull JJoohhnn FFaallssttaadd:://uu//ppffaallssttaadd:://uussrr//pprriinncceettoonn//bbiinn//zzsshh
  355.  
  356. This  function looks up a user in the NIS password map.  The
  357. $$11 expands to the first argument to yypp.  The function  could
  358. have been equivalently defined in one of the following ways:
  359.  
  360. %% ffuunnccttiioonn yypp {{
  361. >>       yyppmmaattcchh $$11 ppaasssswwdd..bbyynnaammee
  362. >> }}
  363. %% ffuunnccttiioonn yypp (()) {{
  364. >>       yyppmmaattcchh $$11 ppaasssswwdd..bbyynnaammee
  365. >> }}
  366. %% ffuunnccttiioonn yypp (()) yyppmmaattcchh $$11 ppaasssswwdd..bbyynnaammee
  367.  
  368. Note that aliases are expanded when the function  definition
  369. is parsed, not when the function is executed.  For example:
  370.  
  371. %% aalliiaass yyppmmaattcchh==eecchhoo
  372. %% yypp ppffaallssttaadd
  373. ppffaallssttaadd::**::33556644::3355::PPaauull JJoohhnn FFaallssttaadd:://uu//ppffaallssttaadd:://uussrr//pprriinncceettoonn//bbiinn//zzsshh
  374.  
  375. Since  the  alias was defined after the function was parsed,
  376. it has no effect on the function's execution.   However,  if
  377. we define the function again with the alias in place:
  378.  
  379. %% ffuunnccttiioonn yypp (()) {{ yyppmmaattcchh $$11 ppaasssswwdd..bbyynnaammee }}
  380. %% yypp ppffaallssttaadd
  381. ppffaallssttaadd ppaasssswwdd..bbyynnaammee
  382.  
  383. it is parsed with the new alias definition in place.  There-
  384. fore, in general you must define aliases before functions.
  385.  
  386. We can make the function take multiple arguments:
  387.  
  388. %% uunnaalliiaass yyppmmaattcchh
  389. %% yypp (()) {{
  390. >>       ffoorr ii
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.                              -7-
  401.  
  402.  
  403. >>       ddoo yyppmmaattcchh $$ii ppaasssswwdd..bbyynnaammee
  404. >>       ddoonnee
  405. >> }}
  406. %% yypp ppffaallssttaadd ssuubbbbaarraaoo ssuukktthhnnkkrr
  407. ppffaallssttaadd::**::33556644::3355::PPaauull JJoohhnn FFaallssttaadd:://uu//ppffaallssttaadd:://uussrr//pprriinncceettoonn//bbiinn//zzsshh
  408. ssuubbbbaarraaoo::**::33333388::3355::KKaarrttiikk SSuubbbbaarraaoo:://uu//ssuubbbbaarraaoo:://uussrr//pprriinncceettoonn//bbiinn//zzsshh
  409. ssuukktthhnnkkrr::**::11226677::3355::RRaahhuull SSuukktthhaannkkaarr:://uu//ssuukktthhnnkkrr:://uussrr//pprriinncceettoonn//bbiinn//ttccsshh
  410.  
  411. The ffoorr ii loops through each of  the  function's  arguments,
  412. setting  ii  equal to each of them in turn.  We can also make
  413. the function do  something  sensible  if  no  arguments  are
  414. given:
  415.  
  416. %% yypp (()) {{
  417. >>       iiff (((( $$## ==== 00 ))))
  418. >>       tthheenn eecchhoo uussaaggee:: yypp nnaammee ......;; ffii
  419. >>       ffoorr ii;; ddoo yyppmmaattcchh $$ii ppaasssswwdd..bbyynnaammee;; ddoonnee
  420. >> }}
  421. %% yypp
  422. uussaaggee:: yypp nnaammee ......
  423. %% yypp ppffaallssttaadd ssuukktthhnnkkrr
  424. ppffaallssttaadd::**::33556644::3355::PPaauull JJoohhnn FFaallssttaadd:://uu//ppffaallssttaadd:://uussrr//pprriinncceettoonn//bbiinn//zzsshh
  425. ssuukktthhnnkkrr::**::11226677::3355::RRaahhuull SSuukktthhaannkkaarr:://uu//ssuukktthhnnkkrr:://uussrr//pprriinncceettoonn//bbiinn//ttccsshh
  426.  
  427. $$##  is the number of arguments supplied to the function.  If
  428. it is equal to zero, we print a usage message; otherwise, we
  429. loop through the arguments, and yyppmmaattcchh all of them.
  430.  
  431. Here's a function that selects a random line from a file:
  432.  
  433. %% rraannddlliinnee (()) {{
  434. >>       iinntteeggeerr zz==$$((wwcc --ll <<$$11))
  435. >>       sseedd --nn $$[[RRAANNDDOOMM %% zz ++ 11]]pp $$11
  436. >> }}
  437. %% rraannddlliinnee //eettcc//mmoottdd
  438. PPHHOOEENNIIXX WWIILLLL BBEE DDOOWWNN bbrriieeffllyy FFrriiddaayy mmoorrnniinngg,, 55//2244//9911 ffrroomm 88 AAMM ttoo
  439. %% rraannddlliinnee //eettcc//mmoottdd
  440. SSuunnOOSS RReelleeaassee 44..11..11 ((PPHHOOEENNIIXX)) ##1199:: TTuuee MMaayy 1144 1199::0033::1155 EEDDTT 11999911
  441. %% rraannddlliinnee //eettcc//mmoottdd
  442. || PPlleeaassee uussee tthhee ""mmssggss"" ccoommmmaanndd ttoo rreeaadd aannnnoouunncceemmeennttss..  RReeffeerr ttoo tthhee   ||
  443. %% eecchhoo $$zz
  444.  
  445. %%
  446.  
  447. rraannddlliinnee  has  a local variable, zz, that holds the number of
  448. lines in the file.  $$[[RRAANNDDOOMM %% zz ++ 11]] expands  to  a  random
  449. number  between  1  and zz.  An expression of the form $$[[...]]
  450. expands to the value of the arithmetic expression within the
  451. brackets,  and  the  RRAANNDDOOMM variable returns a random number
  452. each time it is referenced.  %% is the modulus  operator,  as
  453. in  C.  Therefore, sseedd --nn $$[[RRAANNDDOOMM%%zz++11]]pp picks a random line
  454. from its input, from 1 to zz.
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.                              -8-
  467.  
  468.  
  469. Function  definitions  can  be  viewed  with  the  ffuunnccttiioonnss
  470. builtin:
  471.  
  472. %% ffuunnccttiioonnss rraannddlliinnee
  473. rraannddlliinnee (()) {{
  474.         iinntteeggeerr zz==$$((wwcc --ll <<$$11))
  475.         sseedd --nn $$[[RRAANNDDOOMM %% zz ++ 11]]pp $$11
  476.  
  477. }}
  478. %% ffuunnccttiioonnss
  479. yypp (()) {{
  480.         iiff lleett $$## ==== 00
  481.  
  482.         tthheenn
  483.                 eecchhoo uussaaggee:: yypp nnaammee ......
  484.  
  485.         ffii
  486.         ffoorr ii
  487.         ddoo
  488.                 yyppmmaattcchh $$ii ppaasssswwdd..bbyynnaammee
  489.  
  490.                 ddoonnee
  491.  
  492. }}
  493. rraannddlliinnee (()) {{
  494.         iinntteeggeerr zz==$$((wwcc --ll <<$$11))
  495.         sseedd --nn $$[[RRAANNDDOOMM %% zz ++ 11]]pp $$11
  496.  
  497. }}
  498.  
  499. Here's another one:
  500.  
  501. %% ccxx (()) {{ cchhmmoodd ++xx $$** }}
  502. %% llss --ll ffoooo bbaarr
  503. --rrww--rr----rr----  11 ppffaallssttaadd       2299 MMaayy 2244 0044::3388 bbaarr
  504. --rrww--rr----rr----  11 ppffaallssttaadd       2299 MMaayy 2244 0044::3388 ffoooo
  505. %% ccxx ffoooo bbaarr
  506. %% llss --ll ffoooo bbaarr
  507. --rrwwxxrr--xxrr--xx  11 ppffaallssttaadd       2299 MMaayy 2244 0044::3388 bbaarr
  508. --rrwwxxrr--xxrr--xx  11 ppffaallssttaadd       2299 MMaayy 2244 0044::3388 ffoooo
  509.  
  510. Note that this could also have been implemented as an alias:
  511.  
  512. %% cchhmmoodd 664444 ffoooo bbaarr
  513. %% aalliiaass ccxx==''cchhmmoodd ++xx''
  514. %% ccxx ffoooo bbaarr
  515. %% llss --ll ffoooo bbaarr
  516. --rrwwxxrr--xxrr--xx  11 ppffaallssttaadd       2299 MMaayy 2244 0044::3388 bbaarr
  517. --rrwwxxrr--xxrr--xx  11 ppffaallssttaadd       2299 MMaayy 2244 0044::3388 ffoooo
  518.  
  519.  
  520. Instead of defining a lot of functions in your  ..zzsshhrrcc,  all
  521. of  which  you  may  not  use, it is often better to use the
  522. aauuttoollooaadd builtin.  The idea is, you create a directory where
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.                              -9-
  533.  
  534.  
  535. function  definitions  are stored, declare the names in your
  536. ..zzsshhrrcc, and tell the shell where to look for them.  Whenever
  537. you  reference a function, the shell will automatically load
  538. it into memory.
  539.  
  540. %% mmkkddiirr //ttmmpp//ffuunnss
  541. %% ccaatt >>//ttmmpp//ffuunnss//yypp
  542. yyppmmaattcchh $$11 ppaasssswwdd..bbyynnaammee
  543. ^^DD
  544. %% ccaatt >>//ttmmpp//ffuunnss//ccxx
  545. cchhmmoodd ++xx $$**
  546. ^^DD
  547. %% FFPPAATTHH==//ttmmpp//ffuunnss
  548. %% aauuttoollooaadd ccxx yypp
  549. %% ffuunnccttiioonnss ccxx yypp
  550. uunnddeeffiinneedd ccxx (())
  551. uunnddeeffiinneedd yypp (())
  552. %% cchhmmoodd 775555 //ttmmpp//ffuunnss//{{ccxx,,yypp}}
  553. %% yypp eeggssiirreerr
  554. eeggssiirreerr::**::33221144::3355::EEmmiinn GGuunn SSiirreerr:://uu//eeggssiirreerr:://bbiinn//sshh
  555. %% ffuunnccttiioonnss yypp
  556. yypp (()) {{
  557.         yyppmmaattcchh $$11 ppaasssswwdd..bbyynnaammee
  558. }}
  559.  
  560. This idea has other benefits.  By adding a ##!! header to  the
  561. files, you can make them double as shell scripts.  (Although
  562. it is faster to use them as functions, since a separate pro-
  563. cess is not created.)
  564.  
  565. %% eedd //ttmmpp//ffuunnss//yypp
  566. 2255
  567. ii
  568. ##!! //uussrr//llooccaall//bbiinn//zzsshh
  569. ww
  570. 4422
  571. qq
  572. %% <<//ttmmpp//ffuunnss//yypp
  573. ##!! //uussrr//llooccaall//bbiinn//zzsshh
  574. yyppmmaattcchh $$11 ppaasssswwdd..bbyynnaammee
  575. %% //ttmmpp//ffuunnss//yypp ssuukktthhnnkkrr
  576. ssuukktthhnnkkrr::**::11226677::3355::RRaahhuull SSuukktthhaannkkaarr:://uu//ssuukktthhnnkkrr:://uussrr//pprriinncceettoonn//bbiinn//ttccsshh
  577.  
  578. Now  other people, who may not use zzsshh, or who don't want to
  579. copy all of your ..zzsshhrrcc, may use these  functions  as  shell
  580. scripts.
  581.  
  582. DDiirreeccttoorriieess
  583.  
  584. One  nice  feature  of zzsshh is the way it prints directories.
  585. For example, if we set the prompt like this:
  586.  
  587. pphhooeenniixx%% PPRROOMMPPTT==''%%~~>> ''
  588. ~~>> ccdd ssrrcc
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.                             -10-
  599.  
  600.  
  601. ~~//ssrrcc>>
  602.  
  603. the shell will print the current directory  in  the  prompt,
  604. using  the  ~~  character.  However, zzsshh is smarter than most
  605. other shells in this respect:
  606.  
  607. ~~//ssrrcc>> ccdd ~~ssuubbbbaarraaoo
  608. ~~ssuubbbbaarraaoo>> ccdd ~~mmaarruucchhcckk
  609. ~~mmaarruucchhcckk>> ccdd lliibb
  610. ~~mmaarruucchhcckk//lliibb>> ccdd ffuunn
  611. ~~mmaarruucchhcckk//lliibb//ffuunn>> ffoooo==//uussrr//pprriinncceettoonn//ccoommmmoonn//ssrrcc
  612. ~~mmaarruucchhcckk//lliibb//ffuunn>> ccdd ~~ffoooo
  613. ~~ffoooo>> ccdd ....
  614. //uussrr//pprriinncceettoonn//ccoommmmoonn>> ccdd ssrrcc
  615. ~~ffoooo>> ccdd nneewwss//nnnnttpp
  616. ~~ffoooo//nneewwss//nnnnttpp>> ccdd iinneewwss
  617. ~~ffoooo//nneewwss//nnnnttpp//iinneewwss>>
  618.  
  619. Note that zzsshh prints _o_t_h_e_r users' directories  in  the  form
  620. ~~uusseerr.  Also note that you can set a parameter and use it as
  621. a directory name; zzsshh will act as if ffoooo is a user with  the
  622. login  directory  //uussrr//pprriinncceettoonn//ccoommmmoonn//ssrrcc.  This is conve-
  623. nient, especially if you're  sick  of  seeing  prompts  like
  624. this:
  625.  
  626. pphhooeenniixx:://uussrr//pprriinncceettoonn//ccoommmmoonn//ssrrcc//XX..VV1111RR44//ccoonnttrriibb//cclliieennttss//xxvv//ddooccss>>
  627.  
  628. If  you get stuck in this position, you can give the current
  629. directory a short name, like this:
  630.  
  631. //uussrr//pprriinncceettoonn//ccoommmmoonn//ssrrcc//nneewwss//nnnnttpp//iinneewwss>> iinneewwss==$$PPWWDD
  632. //uussrr//pprriinncceettoonn//ccoommmmoonn//ssrrcc//nneewwss//nnnnttpp//iinneewwss>> eecchhoo ~~iinneewwss
  633. //uussrr//pprriinncceettoonn//ccoommmmoonn//ssrrcc//nneewwss//nnnnttpp//iinneewwss
  634. ~~iinneewwss>>
  635.  
  636. When you reference a directory in the form ~~iinneewwss, the shell
  637. assumes  that you want the directory displayed in this form;
  638. thus simply typing eecchhoo  ~~iinneewwss  or  ccdd  ~~iinneewwss  causes  the
  639. prompt to be shortened.  You can define a shell function for
  640. this purpose:
  641.  
  642. ~~iinneewwss>> nnaammeeddiirr (()) {{ $$11==$$PPWWDD ;;  :: ~~$$11 }}
  643. ~~iinneewwss>> ccdd //uussrr//pprriinncceettoonn//bbiinn
  644. //uussrr//pprriinncceettoonn//bbiinn>> nnaammeeddiirr ppbbiinn
  645. ~~ppbbiinn>> ccdd //vvaarr//ssppooooll//mmaaiill
  646. //vvaarr//ssppooooll//mmaaiill>> nnaammeeddiirr ssppooooll
  647. ~~ssppooooll>> ccdd ..mmssggss
  648. ~~ssppooooll//..mmssggss>>
  649.  
  650. You may want to add this one-line function to your ..zzsshhrrcc.
  651.  
  652. zzsshh can also put the current directory in your title bar, if
  653. you  are  using  a  windowing system.  One way to do this is
  654. with the cchhppwwdd function, which is automatically executed  by
  655.  
  656.  
  657.  
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.                             -11-
  665.  
  666.  
  667. the  shell  whenever you change directory.  If you are using
  668. xterm, this will work:
  669.  
  670. cchhppwwdd (()) {{ pprriinntt --PPnn ''^^[[]]22;;%%~~^^GG'' }}
  671.  
  672. The --PP option tells pprriinntt to  treat  its  arguments  like  a
  673. prompt  string; otherwise the %%~~ would not be expanded.  The
  674. --nn option suppresses the terminating newline, as with  eecchhoo.
  675.  
  676. If you are using an IRIS wwsshh, do this:
  677.  
  678. cchhppwwdd (()) {{ pprriinntt --PPnn ''\\22220011..yy%%~~\\223344'' }}
  679.  
  680. The  pprriinntt --DD command has other uses.  For example, to print
  681. the current directory to standard output in short form,  you
  682. can do this:
  683.  
  684. %% pprriinntt --DD $$PPWWDD
  685. ~~ssuubbbbaarraaoo//ssrrcc
  686.  
  687. and to print each component of the path in short form:
  688.  
  689. %% pprriinntt --DD $$ppaatthh
  690. //bbiinn //uussrr//bbiinn ~~llooccbbiinn ~~llooccbbiinn//XX1111 ~~//bbiinn
  691.  
  692.  
  693. DDiirreeccttoorryy SSttaacckkss
  694.  
  695. If  you  use  csh, you may know about directory stacks.  The
  696. ppuusshhdd command puts the current directory on the  stack,  and
  697. changes  to  a new directory; the ppooppdd command pops a direc-
  698. tory off the stack and changes to it.
  699.  
  700. pphhooeenniixx%% ccdd
  701. pphhooeenniixx%% PPRROOMMPPTT==''ZZ %%~~>> ''
  702. ZZ ~~>> ppuusshhdd //ttmmpp
  703. //ttmmpp ~~
  704. ZZ //ttmmpp>> ppuusshhdd //uussrr//eettcc
  705. //uussrr//eettcc //ttmmpp ~~
  706. ZZ //uussrr//eettcc>> ppuusshhdd //uussrr//bbiinn
  707. //uussrr//bbiinn //uussrr//eettcc //ttmmpp ~~
  708. ZZ //uussrr//bbiinn>> ppooppdd
  709. //uussrr//eettcc //ttmmpp ~~
  710. ZZ //uussrr//eettcc>> ppooppdd
  711. //ttmmpp ~~
  712. ZZ //ttmmpp>> ppuusshhdd //eettcc
  713. //eettcc //ttmmpp ~~
  714. ZZ //eettcc>> ppooppdd
  715. //ttmmpp ~~
  716.  
  717. zzsshh's directory stack commands work similarly.  One  differ-
  718. ence  is the way ppuusshhdd is handled if no arguments are given.
  719. As in csh, this exchanges the top two elements of the direc-
  720. tory stack:
  721.  
  722.  
  723.  
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730.                             -12-
  731.  
  732.  
  733. ZZ //ttmmpp>> ddiirrss
  734. //ttmmpp ~~
  735. ZZ //ttmmpp>> ppuusshhdd
  736. ~~ //ttmmpp
  737.  
  738. unless the stack only has one entry:
  739.  
  740. ZZ ~~>> ppooppdd
  741. //ttmmpp
  742. ZZ //ttmmpp>> ddiirrss
  743. //ttmmpp
  744. ZZ //ttmmpp>> ppuusshhdd
  745. ~~ //ttmmpp
  746. ZZ ~~>>
  747.  
  748. or unless the _P_U_S_H_D_T_O_H_O_M_E option is set:
  749.  
  750. ZZ ~~>> sseettoopptt ppuusshhddttoohhoommee
  751. ZZ ~~>> ppuusshhdd
  752. ~~ ~~ //ttmmpp
  753.  
  754.  
  755. As  an alternative to using directory stacks in this manner,
  756. we can get something like a _d_i_r_e_c_t_o_r_y _h_i_s_t_o_r_y by  setting  a
  757. few more options and parameters:
  758.  
  759. ~~>> DDIIRRSSTTAACCKKSSIIZZEE==88
  760. ~~>> sseettoopptt aauuttooppuusshhdd ppuusshhddmmiinnuuss ppuusshhddssiilleenntt ppuusshhddttoohhoommee
  761. ~~>> aalliiaass ddhh==''ddiirrss --vv''
  762. ~~>> ccdd //ttmmpp
  763. //ttmmpp>> ccdd //uussrr
  764. //uussrr>> ccdd bbiinn
  765. //uussrr//bbiinn>> ccdd ....//ppuubb
  766. //uussrr//ppuubb>> ddhh
  767. 00       //uussrr//ppuubb
  768. 11       //uussrr//bbiinn
  769. 22       //uussrr
  770. 33       //ttmmpp
  771. 44       ~~
  772. //uussrr//ppuubb>> ccdd --33
  773. //ttmmpp>> ddhh
  774. 00       //ttmmpp
  775. 11       //uussrr//ppuubb
  776. 22       //uussrr//bbiinn
  777. 33       //uussrr
  778. 44       ~~
  779. //ttmmpp>> llss ==22//ddff
  780. //uussrr//bbiinn//ddff
  781. //ttmmpp>> ccdd --44
  782. ~~>>
  783.  
  784. Note that ==22 expanded to the second directory in the history
  785. list, and that ccdd --33 recalled the  third  directory  in  the
  786. list.
  787.  
  788.  
  789.  
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796.                             -13-
  797.  
  798.  
  799. You  may  be wondering what all those options do.  _A_U_T_O_P_U_S_H_D
  800. made ccdd act like ppuusshhdd.  (aalliiaass ccdd==ppuusshhdd is not  sufficient,
  801. for  various reasons.)  _P_U_S_H_D_M_I_N_U_S swapped the meaning of ccdd
  802. ++11 and ccdd --11; we want them to mean the opposite of what they
  803. mean in csh, because it makes more sense in this scheme, and
  804. it's easier to type:
  805.  
  806. ~~>> ddhh
  807. 00       ~~
  808. 11       //ttmmpp
  809. 22       //uussrr//ppuubb
  810. 33       //uussrr//bbiinn
  811. 44       //uussrr
  812. ~~>> uunnsseettoopptt ppuusshhddmmiinnuuss
  813. ~~>> ccdd ++11
  814. //ttmmpp>> ddhh
  815. 00       //ttmmpp
  816. 11       ~~
  817. 22       //uussrr//ppuubb
  818. 33       //uussrr//bbiinn
  819. 44       //uussrr
  820. //ttmmpp>> ccdd ++22
  821. //uussrr//ppuubb>>
  822.  
  823. _P_U_S_H_D_S_I_L_E_N_T keeps the  shell  from  printing  the  directory
  824. stack  each  time  we  do a ccdd, and _P_U_S_H_D_T_O_H_O_M_E we mentioned
  825. earlier:
  826.  
  827. //uussrr//ppuubb>> uunnsseettoopptt ppuusshhddssiilleenntt
  828. //uussrr//ppuubb>> ccdd //eettcc
  829. //eettcc //uussrr//ppuubb //ttmmpp ~~ //uussrr//bbiinn //uussrr
  830. //eettcc>> ccdd
  831. ~~ //eettcc //uussrr//ppuubb //ttmmpp ~~ //uussrr//bbiinn //uussrr
  832. ~~>> uunnsseettoopptt ppuusshhddttoohhoommee
  833. ~~>> ccdd
  834. //eettcc ~~ //uussrr//ppuubb //ttmmpp ~~ //uussrr//bbiinn //uussrr
  835. //eettcc>>
  836.  
  837. DDIIRRSSTTAACCKKSSIIZZEE keeps the  directory  stack  from  getting  too
  838. large, much like _H_I_S_T_S_I_Z_E:
  839.  
  840. //eettcc>> sseettoopptt ppuusshhddssiilleenntt
  841. //eettcc>> ccdd //
  842. //>> ccdd //
  843. //>> ccdd //
  844. //>> ccdd //
  845. //>> ccdd //
  846. //>> ccdd //
  847. //>> ccdd //
  848. //>> ccdd //
  849. //>> ddhh
  850. 00       //
  851. 11       //
  852. 22       //
  853.  
  854.  
  855.  
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862.                             -14-
  863.  
  864.  
  865. 33       //
  866. 44       //
  867. 55       //
  868. 66       //
  869. 77       //
  870.  
  871.  
  872. CCoommmmaanndd//PPrroocceessss SSuubbssttiittuuttiioonn
  873.  
  874. Command substitution in zzsshh can take two forms.  In the tra-
  875. ditional form, a command enclosed in backquotes  (``...``)  is
  876. replaced  on  the command line with its output.  This is the
  877. form used by the older shells.  Newer shells (like zzsshh) also
  878. provide  another  form, $$((...)).  This form is much easier to
  879. nest.
  880.  
  881. %% llss --ll ``eecchhoo //vvmmuunniixx``
  882. --rrwwxxrr--xxrr--xx  11 rroooott      11220099770022 MMaayy 1144 1199::0044 //vvmmuunniixx
  883. %% llss --ll $$((eecchhoo //vvmmuunniixx))
  884. --rrwwxxrr--xxrr--xx  11 rroooott      11220099770022 MMaayy 1144 1199::0044 //vvmmuunniixx
  885. %% wwhhoo || ggrreepp mmaadd
  886. ssuubbbbaarraaoo ttttyytt77   MMaayy 2233 1155::0022   ((mmaadd5555ssxx1155..PPrriinnccee))
  887. ppffaallssttaadd ttttyyuu11   MMaayy 2233 1166::2255   ((mmaadd5555ssxx1144..PPrriinnccee))
  888. ssuubbbbaarraaoo ttttyyuu66   MMaayy 2233 1155::0044   ((mmaadd5555ssxx1155..PPrriinnccee))
  889. ppffaallssttaadd ttttyyvv33   MMaayy 2233 1166::2255   ((mmaadd5555ssxx1144..PPrriinnccee))
  890. %% wwhhoo || ggrreepp mmaadd || aawwkk ''{{pprriinntt $$22}}''
  891. ttttyytt77
  892. ttttyyuu11
  893. ttttyyuu66
  894. ttttyyvv33
  895. %% ccdd //ddeevv;; llss --ll $$((wwhhoo ||
  896. >> ggrreepp $$((eecchhoo mmaadd)) ||
  897. >> aawwkk ''{{ pprriinntt $$22 }}''))
  898. ccrrwwxx--ww--------  11 ssuubbbbaarraaoo  2200,,  7711 MMaayy 2233 1188::3355 ttttyytt77
  899. ccrrww----ww--------  11 ppffaallssttaadd  2200,,  8811 MMaayy 2233 1188::4422 ttttyyuu11
  900. ccrrwwxx--ww--------  11 ssuubbbbaarraaoo  2200,,  8866 MMaayy 2233 1188::3388 ttttyyuu66
  901. ccrrww----ww--------  11 ppffaallssttaadd  2200,,  9999 MMaayy 2233 1188::4411 ttttyyvv33
  902.  
  903. Many common  uses  of  command  substitution,  however,  are
  904. superseded by other mechanisms of zzsshh:
  905.  
  906. %% llss --ll ``ttttyy``
  907. ccrrww--rrww--rrww--  11 rroooott      2200,,  2288 MMaayy 2233 1188::3355 //ddeevv//ttttyyqqcc
  908. %% llss --ll $$TTTTYY
  909. ccrrww--rrww--rrww--  11 rroooott      2200,,  2288 MMaayy 2233 1188::3355 //ddeevv//ttttyyqqcc
  910. %% llss --ll ``wwhhiicchh rrnn``
  911. --rrwwxxrr--xxrr--xx  11 rroooott       117722003322 MMaarr  66 1188::4400 //uussrr//pprriinncceettoonn//bbiinn//rrnn
  912. %% llss --ll ==rrnn
  913. --rrwwxxrr--xxrr--xx  11 rroooott       117722003322 MMaarr  66 1188::4400 //uussrr//pprriinncceettoonn//bbiinn//rrnn
  914.  
  915. A  command name with a == prepended is replaced with its full
  916. pathname.  This can be very convenient.  If it's not  conve-
  917. nient for you, you can turn it off:
  918.  
  919.  
  920.  
  921.  
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928.                             -15-
  929.  
  930.  
  931. %% llss
  932. ==ffoooo    ==bbaarr
  933. %% llss ==ffoooo ==bbaarr
  934. zzsshh:: ffoooo nnoott ffoouunndd
  935. %% sseettoopptt nnooeeqquuaallss
  936. %% llss ==ffoooo ==bbaarr
  937. ==ffoooo    ==bbaarr
  938.  
  939.  
  940. Another nice feature is process substitution:
  941.  
  942. %% wwhhoo || ffggrreepp --ff ==((pprriinntt --ll rroooott lleemmkkee sshhggcchhaann ssuubbbbaarraaoo))
  943. rroooott     ccoonnssoollee MMaayy 1199 1100::4411
  944. lleemmkkee    ttttyyqq00   MMaayy 2222 1100::0055   ((nnaarrnniiaa::00..00))
  945. lleemmkkee    ttttyyrr77   MMaayy 2222 1100::0055   ((nnaarrnniiaa::00..00))
  946. lleemmkkee    ttttyyrrdd   MMaayy 2222 1100::0055   ((nnaarrnniiaa::00..00))
  947. sshhggcchhaann  ttttyyss11   MMaayy 2233 1166::5522   ((ggaauuddii..PPrriinncceettoonn..))
  948. ssuubbbbaarraaoo ttttyytt77   MMaayy 2233 1155::0022   ((mmaadd5555ssxx1155..PPrriinnccee))
  949. ssuubbbbaarraaoo ttttyyuu66   MMaayy 2233 1155::0044   ((mmaadd5555ssxx1155..PPrriinnccee))
  950. sshhggcchhaann  ttttyyvvbb   MMaayy 2233 1166::5511   ((ggaauuddii..PPrriinncceettoonn..))
  951.  
  952. A  command of the form ==((...)) is replaced with the name of a
  953. _f_i_l_e containing its output.  (A command substitution, on the
  954. other  hand,  is replaced with the output itself.)  pprriinntt --ll
  955. is like eecchhoo, excepts that it prints its arguments  one  per
  956. line, the way ffggrreepp expects them:
  957.  
  958. %% pprriinntt --ll ffoooo bbaarr
  959. ffoooo
  960. bbaarr
  961.  
  962. We could also have written:
  963.  
  964. %% wwhhoo || ffggrreepp --ff ==((eecchhoo ''rroooott
  965. >> lleemmkkee
  966. >> sshhggcchhaann
  967. >> ssuubbbbaarraaoo''))
  968.  
  969. Using  process  substitution,  you  can edit the output of a
  970. command:
  971.  
  972. %% eedd ==((wwhhoo || ffggrreepp --ff ~~//..ffrriieennddss))
  973. 335555
  974. gg//lleemmkkee//dd
  975. ww //ttmmpp//ffiillbbaarr
  976. 222266
  977. qq
  978. %% ccaatt //ttmmpp//ffiillbbaarr
  979. rroooott     ccoonnssoollee MMaayy 1199 1100::4411
  980. sshhggcchhaann  ttttyyss11   MMaayy 2233 1166::5522   ((ggaauuddii..PPrriinncceettoonn..))
  981. ssuubbbbaarraaoo ttttyytt77   MMaayy 2233 1155::0022   ((mmaadd5555ssxx1155..PPrriinnccee))
  982. ssuubbbbaarraaoo ttttyyuu66   MMaayy 2233 1155::0044   ((mmaadd5555ssxx1155..PPrriinnccee))
  983. sshhggcchhaann  ttttyyvvbb   MMaayy 2233 1166::5511   ((ggaauuddii..PPrriinncceettoonn..))
  984.  
  985.  
  986.  
  987.  
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994.                             -16-
  995.  
  996.  
  997. or easily read archived mail:
  998.  
  999. %% mmaaiill --ff ==((zzccaatt ~~//mmaaiill//oollddzzsshhmmaaiill..ZZ))
  1000. ""//ttmmpp//zzsshhaa0066002244"":: 8844 mmeessssaaggeess,, 00 nneeww,, 4433 uunnrreeaadd
  1001. >>  11  UU  TTOO:: ppffaallssttaadd,, zzsshh ((1100))
  1002.    22  UU  nnyyttiimm!!ttiimm@@uuuunneett..uuuu..nneett,, RRee:: ZZsshh oonn SSppaarrcc11 //SSuunnOOSS 44..00..33
  1003.    33  UU  JJAAMM%%TTPPNN@@uuttrrccggww..uuttcc..ccoomm,, zzsshh ffiixx ((1155))
  1004.    44  UU  ddjjmm@@eenngg..uummdd..eedduu,, wwaayy ttoo ffiinndd oouutt iiff rruunnnniinngg zzsshh?? ((2255))
  1005.    55  UU  ddjjmm@@eenngg..uummdd..eedduu,, RRee:: wwaayy ttoo ffiinndd oouutt iiff rruunnnniinngg zzsshh?? ((1177))
  1006.    66   rr ddjjmm@@eenngg..uummdd..eedduu,, MMeettaa .. ((1188))
  1007.    77  UU  jjaacckk@@ccss..ggllaassggooww..aacc..uukk,, RRee:: pprroobblleemm bbuuiillddiinngg zzsshh ((114477))
  1008.    88  UU  nnyyttiimm!!ttiimm@@uuuunneett..uuuu..nneett,, RRee:: ZZsshh oonn SSppaarrcc11 //SSuunnOOSS 44..00..33
  1009.    99     uurrssaa!!jjmmdd,, AAnnootthheerr ffiixx...... ((6611))
  1010.   1100  UU  ppppllaacceewwaa@@bbbbnn..ccoomm,, RRee:: vv1188ii008844:: ZZsshh 22..0000 -- AA ssmmaallll ccoommppllaaiinntt ((3366))
  1011.   1111  UU  lluubbkkiinn@@ccss..rroocchheesstteerr..eedduu,, PPOOSSIIXX jjoobb ccoonnttrrooll ((3344))
  1012.   1122  UU  yyaallee!!bbrroonnssoonn!!ttaann@@uuuunneett..UUUU..NNEETT
  1013.   1133  UU  bbrreetttt@@rrppii..eedduu,, zzsshh ((3366))
  1014.   1144  SS  ssuubbbbaarraaoo,, zzsshh ssuucckkss!!!!!!!! ((228866))
  1015.   1155  UU  ssnniibbrruu!!dd224411ss000088!!dd224411ss001133!!aallaa@@rreellaayy..EEUU..nneett,, zzsshh ((116655))
  1016.   1166  UU  nnyyttiimm!!ttiimm@@uuuunneett..UUUU..NNEETT,, RRee:: ZZsshh oonn SSppaarrcc11 //SSuunnOOSS 44..00..33
  1017.   1177  UU  ssuubbbbaarraaoo,, zzsshh iiss aa jjuunnkk sshheellll ((4433))
  1018.   1188  UU  aammaarraanntthh@@vveellaa..aaccss..ooaakkllaanndd..eedduu,, zzsshh ((3333))
  1019. 4433uu//8844 11:: xx
  1020. %% llss --ll //ttmmpp//zzsshhaa0066002244
  1021. //ttmmpp//zzsshhaa0066002244 nnoott ffoouunndd
  1022.  
  1023. Note that the shell creates a temporary file, and deletes it
  1024. when the command is finished.
  1025.  
  1026. %% ddiiffff ==((llss)) ==((llss --FF))
  1027. 33cc33
  1028. << ffoorrttuunnee
  1029. ------
  1030. >> ffoorrttuunnee**
  1031. 1100cc1100
  1032. << ssttrrffiillee
  1033. ------
  1034. >> ssttrrffiillee**
  1035.  
  1036. If  you  read zzsshh's man page, you may notice that <<((...))  is
  1037. another form of process substitution  which  is  similar  to
  1038. ==((...)).   There  is an important difference between the two.
  1039. In the <<((...)) case, the shell creates a  named  pipe  (FIFO)
  1040. instead  of  a file.  This is better, since it does not fill
  1041. up the file system; but it does not work in all  cases.   In
  1042. fact,  if we had replaced ==((...)) with <<((...)) in the examples
  1043. above, all of them would have  stopped  working  except  for
  1044. ffggrreepp  --ff  <<((...)).  You can not edit a pipe, or open it as a
  1045. mail folder; ffggrreepp, however, has no problem with  reading  a
  1046. list  of  words from a pipe.  You may wonder why ddiiffff <<((ffoooo))
  1047. bbaarr doesn't work, since ffoooo || ddiiffff  --  bbaarr  works;  this  is
  1048. because ddiiffff creates a temporary file if it notices that one
  1049. of its arguments is --, and then copies its standard input to
  1050. the temporary file.
  1051.  
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.                             -17-
  1061.  
  1062.  
  1063. >>((...))  is  just like <<((...)) except that the command between
  1064. the parentheses will get its input from the named pipe.
  1065.  
  1066. %% ddvviippss --oo >>((llpprr)) zzsshh..ddvvii
  1067.  
  1068.  
  1069. RReeddiirreeccttiioonn
  1070.  
  1071. Apart from all the  regular  redirections  like  the  Bourne
  1072. shell  has,  zzsshh  can do more.  You can send the output of a
  1073. command to more than one file, by specifying  more  redirec-
  1074. tions like
  1075.  
  1076. %% eecchhoo HHeelllloo WWoorrlldd >>ffiillee11 >>ffiillee22
  1077.  
  1078. and  the text will end up in both files.  Similarly, you can
  1079. send the output to a file and into a pipe:
  1080.  
  1081. %% mmaakkee >> mmaakkee..lloogg || ggrreepp EErrrroorr
  1082.  
  1083. The same goes for input.  You can make the input of  a  com-
  1084. mand come from more than one file.
  1085.  
  1086. %% ssoorrtt <<ffiillee11 <<ffiillee22 <<ffiillee33
  1087.  
  1088. The  command  will  first  get  the contents of file1 as its
  1089. standard input, then those of file2 and finally the contents
  1090. of file3.  This, too, works with pipes.
  1091.  
  1092. %% ccuutt --dd:: --ff11 //eettcc//ppaasssswwdd || ssoorrtt <<nneewwnnaammeess
  1093.  
  1094. The  sort will get as its standard input first the output of
  1095. ccuutt and then the contents of nneewwnnaammeess.
  1096.  
  1097. Suppose you would like to watch the  standard  output  of  a
  1098. command  on  your  terminal,  but  want to pipe the standard
  1099. error to another command.  An easy way to do this in zzsshh  is
  1100. by redirecting the standard error using 22>> >>((...)).
  1101.  
  1102. %% ffiinndd // --nnaammee ggaammeess 22>> >>((ggrreepp --vv ''PPeerrmmiissssiioonn'' >> rreeaalleerrrroorrss))
  1103.  
  1104. The  above  redirection  will actually be implemented with a
  1105. regular pipe, not a temporary named pipe.
  1106.  
  1107. AAlliiaassiinngg
  1108.  
  1109. Often-used commands can be abbreviated with an alias:
  1110.  
  1111. %% aalliiaass uucc==uunnccoommpprreessss
  1112. %% llss
  1113. hhaannooii..ZZ
  1114. %% uucc hhaannooii
  1115. %% llss
  1116. hhaannooii
  1117.  
  1118.  
  1119.  
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126.                             -18-
  1127.  
  1128.  
  1129. or commands with certain desired options:
  1130.  
  1131. %% aalliiaass ffmm==''ffiinnggeerr --mm''
  1132. %% ffmm rroooott
  1133. LLooggiinn nnaammee:: rroooott                        IInn rreeaall lliiffee:: OOppeerraattoorr
  1134. DDiirreeccttoorryy:: //                            SShheellll:: //bbiinn//ccsshh
  1135. OOnn ssiinnccee MMaayy 1199 1100::4411::1155 oonn ccoonnssoollee     33 ddaayyss 55 hhoouurrss IIddllee TTiimmee
  1136. NNoo uunnrreeaadd mmaaiill
  1137. NNoo PPllaann..
  1138.  
  1139. %% aalliiaass lloocckk==''lloocckk --pp --6600000000''
  1140. %% lloocckk
  1141. lloocckk:: //ddeevv//ttttyyrr44 oonn pphhooeenniixx.. ttiimmeeoouutt iinn 6600000000 mmiinnuutteess
  1142. ttiimmee nnooww iiss FFrrii MMaayy 2244 0044::2233::1188 EEDDTT 11999911
  1143. KKeeyy::
  1144.  
  1145. %% aalliiaass ll==''llss --AAFF''
  1146. %% ll //
  1147. ..bbaasshh__hhiissttoorryy              kkaaddbb**
  1148. ..bbaasshhrrcc                    lliibb@@
  1149. ..ccsshhrrcc                     lliicceennsseedd//
  1150. ..eexxrrcc                      lloosstt++ffoouunndd//
  1151. ..llooggiinn                     mmaaccssyymmaa
  1152. ...
  1153.  
  1154. Aliases can also be used to replace old commands:
  1155.  
  1156. %% aalliiaass ggrreepp==eeggrreepp ppss==ssppss mmaakkee==ggmmaakkee
  1157. %% aalliiaass wwhhooaammii==''eecchhoo rroooott''
  1158. %% wwhhooaammii
  1159. rroooott
  1160.  
  1161. or to define new ones:
  1162.  
  1163. %% ccdd //
  1164. %% aalliiaass sszz==''llss --ll || ssoorrtt --nn ++33 || ttaaiill --1100''
  1165. %% sszz
  1166. ddrrwwxxrr--ssrr--xx  77 bbiinn          33007722 MMaayy 2233 1111::5599 eettcc
  1167. ddrrwwxxrrwwxxrrwwxx 2266 rroooott         55112200 MMaayy 2244 0044::2200 ttmmpp
  1168. ddrrwwxxrr--xxrr--xx  22 rroooott         88119922 DDeecc 2266 1199::3344 lloosstt++ffoouunndd
  1169. ddrrwwxxrr--ssrr--xx  22 bbiinn         1144884488 MMaayy 2233 1188::4488 ddeevv
  1170. --rr----rr----rr----  11 rroooott       114400552200 DDeecc 2266 2200::0088 bboooott
  1171. --rrwwxxrr--xxrr--xx  11 rroooott       331111117722 DDeecc 2266 2200::0088 kkaaddbb
  1172. --rrwwxxrr--xxrr--xx  11 rroooott      11220099669955 AApprr 1166 1155::3333 vvmmuunniixx..oolldd
  1173. --rrwwxxrr--xxrr--xx  11 rroooott      11220099770022 MMaayy 1144 1199::0044 vvmmuunniixx
  1174. --rrwwxxrr--xxrr--xx  11 rroooott      11220099775588 MMaayy 2211 1122::2233 vvmmuunniixx..nneeww..kkeerrnneellmmaapp..oolldd
  1175. --rrwwxxrr--xxrr--xx  11 rroooott      11771111884488 DDeecc 2266 2200::0088 vvmmuunniixx..oorrgg
  1176. %% ccdd
  1177. %% aalliiaass rraabbllee==''llss --AAFFttrrdd **((RR))'' nnrraabbllee==''llss --AAFFttrrdd **((^^RR))''
  1178. %% rraabbllee
  1179. RREEAADDMMEE      ffuunncc//       bbiinn//        ppuubb//        NNeewwss//       ssrrcc//
  1180. nniicceeccoolloorrss  eettcc//        ssccrr//        ttmmpp//        iirriiss//       zzsshh**
  1181. %% nnrraabbllee
  1182. MMaaiillbbooxxeess//  mmaaiill//       nnootteess
  1183.  
  1184.  
  1185.  
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192.                             -19-
  1193.  
  1194.  
  1195. (The pattern **((RR)) matches all readable files in the  current
  1196. directory, and **((^^RR)) matches all unreadable files.)
  1197.  
  1198. Most  other  shells  have  aliases  of  this  kind  (_c_o_m_m_a_n_d
  1199. aliases).  However, zzsshh also has _g_l_o_b_a_l aliases,  which  are
  1200. substituted  anywhere on a line.  Global aliases can be used
  1201. to abbreviate frequently-typed usernames, hostnames, etc.
  1202.  
  1203. %% aalliiaass --gg mmee==ppffaallssttaadd gguunn==eeggssiirreerr mmjjmm==mmaarruucchhcckk
  1204. %% wwhhoo || ggrreepp mmee
  1205. ppffaallssttaadd ttttyypp00   MMaayy 2244 0033::3399   ((mmiicckkeeyy..PPrriinncceettoonn))
  1206. ppffaallssttaadd ttttyypp55   MMaayy 2244 0033::4422   ((mmiicckkeeyy..PPrriinncceettoonn))
  1207. %% ffmm gguunn
  1208. LLooggiinn nnaammee:: eeggssiirreerr                     IInn rreeaall lliiffee:: EEmmiinn GGuunn SSiirreerr
  1209. DDiirreeccttoorryy:: //uu//eeggssiirreerr                   SShheellll:: //bbiinn//sshh
  1210. LLaasstt llooggiinn TThhuu MMaayy 2233 1199::0055 oonn ttttyyqq33 ffrroomm bbooww..PPrriinncceettoonn..EEDD
  1211. NNeeww mmaaiill rreecceeiivveedd FFrrii MMaayy 2244 0022::3300::2288 11999911;;
  1212.   uunnrreeaadd ssiinnccee FFrrii MMaayy 2244 0022::3300::2277 11999911
  1213. %% aalliiaass --gg pphhxx==pphhooeenniixx..pprriinncceettoonn..eedduu wwaarrcc==wwuuaarrcchhiivvee..wwuussttll..eedduu
  1214. %% ffttpp wwaarrcc
  1215. CCoonnnneecctteedd ttoo wwuuaarrcchhiivvee..wwuussttll..eedduu..
  1216.  
  1217. Here are some more interesting uses.
  1218.  
  1219. %% aalliiaass --gg MM==''|| mmoorree'' GGFF==''|| ffggrreepp --ff ~~//..ffrriieennddss''
  1220. %% wwhhoo MM   ## _p_i_p_e_s _t_h_e _o_u_t_p_u_t _o_f wwhhoo _t_h_r_o_u_g_h mmoorree
  1221. %% wwhhoo GGFF  ## _s_e_e _i_f _y_o_u_r _f_r_i_e_n_d_s _a_r_e _o_n
  1222. %% ww GGFF    ## _s_e_e _w_h_a_t _y_o_u_r _f_r_i_e_n_d_s _a_r_e _d_o_i_n_g
  1223.  
  1224. Another example makes use of zzsshh's process substitution.  If
  1225. you run NIS, and you miss being able to do this:
  1226.  
  1227. %% ggrreepp ppffaallssttaadd //eettcc//ppaasssswwdd
  1228.  
  1229. you  can  define  an  alias that will seem more natural than
  1230. yyppmmaattcchh ppffaallssttaadd ppaasssswwdd:
  1231.  
  1232. %% aalliiaass --gg PPAASSSS==''<<((yyppccaatt ppaasssswwdd))''
  1233. %% ggrreepp ppffaallssttaadd PPAASSSS
  1234. ppffaallssttaadd::**::33556644::3355::PPaauull JJoohhnn FFaallssttaadd:://uu//ppffaallssttaadd:://uussrr//pprriinncceettoonn//bbiinn//zzsshh
  1235.  
  1236. If you're really crazy, you can even call it //eettcc//ppaasssswwdd:
  1237.  
  1238. %% aalliiaass --gg //eettcc//ppaasssswwdd==''<<((yyppccaatt ppaasssswwdd))''
  1239. %% ggrreepp ppffaallssttaadd //eettcc//ppaasssswwdd
  1240. ppffaallssttaadd::**::33556644::3355::PPaauull JJoohhnn FFaallssttaadd:://uu//ppffaallssttaadd:://uussrr//pprriinncceettoonn//bbiinn//zzsshh
  1241.  
  1242. The last example shows one of the perils of global  aliases;
  1243. they  have a lot of potential to cause confusion.  For exam-
  1244. ple, if you defined a global alias called || (which is possi-
  1245. ble), zzsshh would begin to act very strangely; every pipe sym-
  1246. bol would be replaced with the text of your alias.  To  some
  1247. extent,  global  aliases are like macros in C; discretion is
  1248. advised in using them and in choosing names for them.  Using
  1249.  
  1250.  
  1251.  
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258.                             -20-
  1259.  
  1260.  
  1261. names  in all caps is not a bad idea, especially for aliases
  1262. which introduce shell metasyntax (like MM and GGFF above).
  1263.  
  1264. Note that zzsshh aliases are not like csh aliases.  The  syntax
  1265. for  defining  them is different, and they do not have argu-
  1266. ments.  All your favorite csh aliases will probably not work
  1267. under zzsshh.  For example, if you try:
  1268.  
  1269. aalliiaass rrmm mmvv ''\\!!** //ttmmpp//wwaasstteebbaasskkeett''
  1270.  
  1271. no  aliases  will  be  defined,  but  zzsshh will not report an
  1272. error.  In csh, this line defines an  alias  that  makes  rrmm
  1273. safe---files  that  are  rrmm'd  will  be moved to a temporary
  1274. directory instead of instantly destroyed.  In zzsshh's  syntax,
  1275. however,  this  line  asks  the  shell to print any existing
  1276. alias definitions for rrmm, mmvv, or !!** //ttmmpp//wwaasstteebbaasskkeett.  Since
  1277. there  are  none, most likely, the shell will not print any-
  1278. thing, although aalliiaass will return a nonzero exit code.   The
  1279. proper syntax is this:
  1280.  
  1281. aalliiaass rrmm==''mmvv \\!!** //ttmmpp//wwaasstteebbaasskkeett''
  1282.  
  1283. However, this won't work either:
  1284.  
  1285. %% rrmm ffoooo..ddvvii
  1286. zzsshh:: nnoo mmaattcchheess ffoouunndd:: !!**
  1287.  
  1288. While  this makes rrmm safe, it is certainly not what the user
  1289. intended.  In zzsshh, you must use a shell function for this:
  1290.  
  1291. %% uunnaalliiaass rrmm
  1292. %% rrmm (()) {{ mmvv $$** //ttmmpp//wwaasstteebbaasskkeett }}
  1293. %% rrmm ffoooo..ddvvii
  1294. %% llss //ttmmpp//wwaasstteebbaasskkeett
  1295. ffoooo..ddvvii
  1296.  
  1297. While this is much cleaner and easier to read  (I  hope  you
  1298. will  agree), it is not csh-compatible.  Therefore, a script
  1299. to convert csh aliases and variables has been provided.  You
  1300. should  only  need  to  use it once, to convert all your csh
  1301. aliases and parameters to zzsshh format:
  1302.  
  1303. %% ccsshh
  1304. ccsshh>> aalliiaass
  1305. ll       llss --AAFF
  1306. mmoorree    lleessss
  1307. oonn      llaasstt --22 !!::11 ;; wwhhoo || ggrreepp !!::11
  1308. ccsshh>> eexxiitt
  1309. %% cc22zz >>nneeaatt__zzsshh__aalliiaasseess
  1310. %% ccaatt nneeaatt__zzsshh__aalliiaasseess
  1311. aalliiaass ll==''llss --AAFF''
  1312. aalliiaass mmoorree==''lleessss''
  1313. oonn (()) {{ llaasstt --22 $$11 ;; wwhhoo || ggrreepp $$11 }}
  1314. ......
  1315.  
  1316.  
  1317.  
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324.                             -21-
  1325.  
  1326.  
  1327. The first two aliases were converted to regular zzsshh aliases,
  1328. while  the  third,  since it needed to handle arguments, was
  1329. converted to a function.  cc22zz can convert  most  aliases  to
  1330. zzsshh  format  without any problems.  However, if you're using
  1331. some really arcane csh tricks, or if you have an alias  with
  1332. a  name  like ddoo (which is reserved in zzsshh), you may have to
  1333. fix some of the aliases by hand.
  1334.  
  1335. The cc22zz script checks your csh setup, and produces a list of
  1336. zzsshh commands which replicate your aliases and parameter set-
  1337. tings as closely as possible.  You could include its  output
  1338. in your startup file, ..zzsshhrrcc.
  1339.  
  1340. HHiissttoorryy
  1341.  
  1342. There  are  several  ways to manipulate history in zzsshh.  One
  1343. way is to use csh-style !! history:
  1344.  
  1345. %% //uussrr//llooccaall//bbiinn//!!::00 !!--22**::ss//ffoooo//bbaarr// >>>>!!$$
  1346.  
  1347. If you don't want to use this, you can turn it off by typing
  1348. sseettoopptt  nnoobbaanngghhiisstt.   If you are afraid of accidentally exe-
  1349. cuting the wrong command you can set the _H_I_S_T_V_E_R_I_F_Y  option.
  1350. If  this  option  is  set, commands that result from history
  1351. expansion will not be executed immediately, but will be  put
  1352. back into the editor buffer for further consideration.
  1353.  
  1354. If  you're  not  familiar  with !! history, here follows some
  1355. explanation.  History substitutions always start with  a  !!,
  1356. commonly  called  "bang".   After  the !! comes an (optional)
  1357. designation of which "event" (command) to use, then a colon,
  1358. and  then a designation of what word of that command to use.
  1359. For example, !!--_n refers to the command _n commands ago.
  1360.  
  1361. %% llss
  1362. ffoooo  bbaarr
  1363. %% ccdd ffoooo
  1364. %% !!--22
  1365. llss
  1366. bbaazz  bbaamm
  1367.  
  1368. No word designator was used, which means that the whole com-
  1369. mand  referred  to  was  repeated.  Note that the shell will
  1370. echo the result of the history substitution.  The word  des-
  1371. ignator  can, among other things, be a number indicating the
  1372. argument to use, where 00 is the command.
  1373.  
  1374. %% //uussrr//bbiinn//llss ffoooo
  1375. ffoooo
  1376. %% !!::00 bbaarr
  1377. //uussrr//bbiinn//llss bbaarr
  1378. bbaarr
  1379.  
  1380. In this example, no event designator was used,  which  tells
  1381.  
  1382.  
  1383.  
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390.                             -22-
  1391.  
  1392.  
  1393. zzsshh  to  use  the  previous command.  A $$ specifies the last
  1394. argument
  1395.  
  1396. %% mmkkddiirr //uussrr//llooccaall//lliibb//eemmaaccss//ssiittee--lliisspp//ccaallcc
  1397. %% ccdd !!::$$
  1398. ccdd //uussrr//llooccaall//lliibb//eemmaaccss//ssiittee--lliisspp//ccaallcc
  1399.  
  1400. If you use more words of the same command, only the first  !!
  1401. needs an event designator.
  1402.  
  1403. %% mmaakkee pprriigg >>>> mmaakkee..lloogg
  1404. mmaakkee:: ****** NNoo rruullee ttoo mmaakkee ttaarrggeett ``pprriigg''..  SSttoopp..
  1405. %% ccdd ssrrcc
  1406. %% !!--22::00 pprroogg >>>> !!::$$
  1407. mmaakkee pprroogg >>>> mmaakkee..lloogg
  1408.  
  1409. This  is different from csh, where a bang with no event des-
  1410. ignator always refers to the previous command.  If you actu-
  1411. ally like this behaviour, set the _C_S_H_J_U_N_K_I_E_H_I_S_T_O_R_Y option.
  1412.  
  1413. %% sseettoopptt ccsshhjjuunnkkiieehhiissttoorryy
  1414. %% !!--22::00 pprroogg22 >>>> !!::$$
  1415. mmaakkee pprroogg22 >>>> ccsshhjjuunnkkiieehhiissttoorryy
  1416.  
  1417. Another  way  to  use history is to use the ffcc command.  For
  1418. example, if you type an erroneous command:
  1419.  
  1420. %% ffoorr ii iinn ``ccaatt //eettcc//cclliieennttss``
  1421.  ddoo
  1422.  rrppuu $$ii
  1423.  ddoonnee
  1424. zzsshh:: ccoommmmaanndd nnoott ffoouunndd:: rrppuu
  1425. zzsshh:: ccoommmmaanndd nnoott ffoouunndd:: rrppuu
  1426. zzsshh:: ccoommmmaanndd nnoott ffoouunndd:: rrppuu
  1427. ...
  1428.  
  1429. typing ffcc will execute an editor on this  command,  allowing
  1430. you  to  fix it.  (The default editor is vvii, by the way, not
  1431. eedd).
  1432.  
  1433. %% ffcc
  1434. 4499
  1435. //rrppuu//ss////rruupp//pp
  1436.  rruupp $$ii
  1437. ww
  1438. 4499
  1439. qq
  1440. ffoorr ii iinn ``ccaatt //eettcc//cclliieennttss``
  1441.  ddoo
  1442.  rruupp $$ii
  1443.  ddoonnee
  1444.         bbeeaamm    uupp  22 ddaayyss,, 1100::1177,,    llooaadd aavveerraaggee:: 00..8866,, 00..8800,, 00..5500
  1445.          bbooww    uupp  44 ddaayyss,,  88::4411,,    llooaadd aavveerraaggee:: 00..9911,, 00..8800,, 00..5500
  1446.         bbuurrnn    uupp          1177::1188,,    llooaadd aavveerraaggee:: 00..9911,, 00..8800,, 00..5500
  1447.  
  1448.  
  1449.  
  1450.  
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456.                             -23-
  1457.  
  1458.  
  1459.        bbuurrsstt    uupp  99 ddaayyss,,  11::4499,,    llooaadd aavveerraaggee:: 00..9955,, 00..8800,, 00..5500
  1460.          ttaann    uupp          1111::1144,,    llooaadd aavveerraaggee:: 00..9911,, 00..8800,, 00..5500
  1461.        bbaatthhee    uupp  33 ddaayyss,, 1177::4499,,    llooaadd aavveerraaggee:: 11..8844,, 11..7799,, 11..5500
  1462.         bbiirrdd    uupp  11 ddaayy,,   99::1133,,    llooaadd aavveerraaggee:: 11..9955,, 11..8822,, 11..5511
  1463.       bboonnnneett    uupp  22 ddaayyss,, 2211::1188,,    llooaadd aavveerraaggee:: 00..9933,, 00..8800,, 00..5500
  1464. ...
  1465.  
  1466. A variant of the ffcc command is rr, which redoes the last com-
  1467. mand, with optional changes:
  1468.  
  1469. %% eecchhoo ffoooo
  1470. ffoooo
  1471. %% rr
  1472. eecchhoo ffoooo
  1473. ffoooo
  1474.  
  1475. %% eecchhoo ffoooo
  1476. ffoooo
  1477. %% rr ffoooo==bbaarr
  1478. eecchhoo bbaarr
  1479. bbaarr
  1480.  
  1481.  
  1482. CCoommmmaanndd LLiinnee EEddiittiinngg
  1483.  
  1484. zzsshh's  command  line  editor, ZZLLEE, is quite powerful.  It is
  1485. designed to emulate either  emacs  or  vi;  the  default  is
  1486. emacs.   To  set  the bindings for vi mode, type bbiinnddkkeeyy --vv.
  1487. If your EEDDIITTOORR or VVIISSUUAALL environment  variable  is  vi,  zzsshh
  1488. will  use  vi  emulation by default.  You can then switch to
  1489. emacs mode with bbiinnddkkeeyy --ee.
  1490.  
  1491. In addition to basic editing, the shell allows you to recall
  1492. previous  lines in the history.  In emacs mode, this is done
  1493. with _^_P (control-P) or (on many terminals) with the  cursor-
  1494. up key:
  1495.  
  1496. %% llss ~~
  1497. --           RREEAADDMMEE      ffiillee        mmaaiill        ppuubb         ttmmpp
  1498. MMaaiillbbooxxeess   bbiinn         ffuunncc        nniicceeccoolloorrss  ssccrr         zzsshh
  1499. NNeewwss        eettcc         iirriiss        nnootteess       ssrrcc
  1500. %% eecchhoo ffoooobbaarr
  1501. ffoooobbaarr
  1502. %% _^_P
  1503. %% eecchhoo ffoooobbaarr_^_P
  1504. %% llss ~~__
  1505.  
  1506. Pressing  _^_P once brings up the previous line (eecchhoo ffoooobbaarr);
  1507. pressing it again brings up the line  before  that  (llss  ~~).
  1508. The  cursor  is left at the end of the line, allowing you to
  1509. edit the line if  desired  before  executing  it.   In  many
  1510. cases,  ZZLLEE eliminates the need for the ffcc command, since it
  1511. is powerful enough to handle even multiline commands:
  1512.  
  1513.  
  1514.  
  1515.  
  1516.  
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522.                             -24-
  1523.  
  1524.  
  1525. %% ffoorr ii iinn aa bb cc dd ee
  1526. >> ddoo
  1527. >> eecchhoo $$ii
  1528. >> ddoonnee
  1529. aa
  1530. bb
  1531. cc
  1532. dd
  1533. ee
  1534. %% _^_P
  1535. %% ffoorr ii iinn aa bb cc dd ee
  1536.  ddoo
  1537.  eecchhoo $$ii
  1538.  ddoonnee__
  1539.  
  1540. Now you can just move up to the part you want to change...
  1541.  
  1542. %% ffoorr ii iinn aa__ bb cc dd ee
  1543.  ddoo
  1544.  eecchhoo $$ii
  1545.  ddoonnee
  1546.  
  1547. change it, and execute the new command.
  1548.  
  1549. %% ffoorr ii iinn ff gg hh ii jj
  1550.  ddoo
  1551.  eecchhoo $$ii
  1552.  ddoonnee
  1553. ff
  1554. gg
  1555. hh
  1556. ii
  1557. jj
  1558.  
  1559. Also, you can search the history for a certain command using
  1560. _E_S_C_-_P, this will look for the last command that started with
  1561. the (part of the) word at the beginning of the current line.
  1562. Hitting _E_S_C_-_P another time gets you the command before that,
  1563. etc.
  1564.  
  1565. %% sseett _E_S_C_-_P
  1566. %% sseettoopptt aauuttoolliisstt _E_S_C_-_P
  1567. %% sseettoopptt nnooccoorrrreecctt__
  1568.  
  1569. Another way is to do an incremental search, emacs-style:
  1570.  
  1571. %% _^_R
  1572. %% __
  1573. ii--sseeaarrcchh::
  1574.  
  1575. %% llss__ //uussrr//bbiinn
  1576. ii--sseeaarrcchh:: ll
  1577.  
  1578. %% ddaattee >> ffooooffiillee..__cc
  1579.  
  1580.  
  1581.  
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588.                             -25-
  1589.  
  1590.  
  1591. ii--sseeaarrcchh:: llee
  1592.  
  1593. Suppose you have retrieved an old history event  in  one  of
  1594. these ways and would like to execute several consecutive old
  1595. commands starting with this one.  ^^OO will execute  the  cur-
  1596. rent  command and then put the next command from the history
  1597. into the editor buffer.  Typing ^^OO several times will there-
  1598. fore  reexecute  several  consecutive commands from the his-
  1599. tory.  Of course, you can edit some  of  those  commands  in
  1600. between.
  1601.  
  1602. In  addition  to completion (see below), _T_A_B performs expan-
  1603. sion if possible.
  1604.  
  1605. %% llss **..cc_T_A_B
  1606. %% llss ffooooffiillee..cc ffoorrttuunnee..cc rrnndd..cc ssttrrffiillee..cc uunnssttrr..cc__
  1607.  
  1608. For example, suppose you have a bunch of weird files  in  an
  1609. important directory:
  1610.  
  1611. %% llss
  1612.   ** ** **       ;; && %% $$????ffoooo  ddssppffookk        ffoooo..cc
  1613.   !!""ffoooo""!!       `` \\ ``         ffoooo           rrrrrr
  1614.  
  1615. You want to remove them, but you don't want to damage ffoooo..cc.
  1616. Here is one way to do this:
  1617.  
  1618. %% rrmm **_T_A_B
  1619. %% rrmm \\ \\ \\**\\ \\**\\ \\**\\ \\ \\  \\!!\\""ffoooo\\""\\!! \\;;\\ \\&&\\ %%\\ \\$$''
  1620. ''''ffoooo \\``\\ \\\\\\ \\`` ddssppffookk ffoooo ffoooo..cc rrrrrr__
  1621.  
  1622. When you expand **, zzsshh inserts the names of  all  the  files
  1623. into  the  editing  buffer, with proper shell quoting.  Now,
  1624. just move back and remove ffoooo..cc from the buffer:
  1625.  
  1626. %% rrmm \\ \\ \\**\\ \\**\\ \\**\\ \\ \\  \\!!\\""ffoooo\\""\\!! \\;;\\ \\&&\\ %%\\ \\$$''
  1627. ''''ffoooo \\``\\ \\\\\\ \\`` ddssppffookk ffoooo rr__rrrr
  1628.  
  1629. and press return.  Everything except ffoooo..cc will  be  deleted
  1630. from  the  directory.  If you do not want to actually expand
  1631. the current word, but would like to  see  what  the  matches
  1632. are, type ^^XXgg.
  1633.  
  1634. %% rrmm ff**_^_X_g
  1635. ffoooo    ffoooo..cc
  1636. %% rrmm ff**__
  1637.  
  1638. Here's  another trick; let's say you have typed this command
  1639. in:
  1640.  
  1641. %% ggcccc --oo xx..oouutt ffoooobb..cc --gg --WWppooiinntteerr--aarriitthh --WWttrriiggrraapphhss__
  1642.  
  1643. and you forget which library you want.  You need  to  escape
  1644. out  for  a  minute and check by typing llss //uussrr//lliibb, or some
  1645.  
  1646.  
  1647.  
  1648.  
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654.                             -26-
  1655.  
  1656.  
  1657. other such command; but you don't want to retype  the  whole
  1658. command  again,  and  you can't press return now because the
  1659. current command is incomplete.  In zzsshh, you can put the line
  1660. on  the  _b_u_f_f_e_r _s_t_a_c_k, using _E_S_C_-_Q, and type some other com-
  1661. mands.  The next time a prompt is printed, the ggcccc line will
  1662. be  popped off the stack and put in the editing buffer auto-
  1663. matically; you can then enter the proper  library  name  and
  1664. press  return  (or,  _E_S_C_-_Q  again  and  look  for some other
  1665. libraries whose names you forgot).
  1666.  
  1667. A similar situation: what if you forget the  option  to  gcc
  1668. that  finds  bugs using AI techniques?  You could either use
  1669. _E_S_C_-_Q again, and type mmaann ggcccc, or  you  could  press  _E_S_C_-_H,
  1670. which  essentially  does the same thing; it puts the current
  1671. line on the buffer stack, and executes the command  rruunn--hheellpp
  1672. ggcccc, where rruunn--hheellpp is an alias for mmaann.
  1673.  
  1674. Another  interesting  command  is  _E_S_C_-_A.  This executes the
  1675. current line, but retains it  in  the  buffer,  so  that  it
  1676. appears  again  when  the next prompt is printed.  Also, the
  1677. cursor stays in the same place.  This is useful for  execut-
  1678. ing a series of similar commands:
  1679.  
  1680. %% cccc ggrrookk..cc --gg --llcc --llggll --llssuunn --llmmaalllloocc --BBssttaattiicc --oo bb..oouutt
  1681. %% cccc ffuubbaarr..cc --gg --llcc --llggll --llssuunn --llmmaalllloocc --BBssttaattiicc --oo bb..oouutt
  1682. %% cccc ffoooobbllee..cc --gg --llcc --llggll --llssuunn --llmmaalllloocc --BBssttaattiicc --oo bb..oouutt
  1683.  
  1684.  
  1685. The _E_S_C_-_' command is useful for managing the shell's quoting
  1686. conventions.  Let's say you want to print this string:
  1687.  
  1688. ddoonn''tt ddoo tthhaatt;; ttyyppee ''rrmm --rrff \\**'',, wwiitthh aa \\ bbeeffoorree tthhee **..
  1689.  
  1690. All that is necessary is to type it into the editing buffer:
  1691.  
  1692. %% ddoonn''tt ddoo tthhaatt;; ttyyppee ''rrmm --rrff \\**'',, wwiitthh aa \\ bbeeffoorree tthhee **..
  1693.  
  1694. press _E_S_C_-_' (escape-quote):
  1695.  
  1696. %% ''ddoonn''\\''''tt ddoo tthhaatt;; ttyyppee ''\\''''rrmm --rrff \\**''\\'''',, wwiitthh aa \\ bbeeffoorree tthhee **..''
  1697.  
  1698. then move to the beginning and add the eecchhoo command.
  1699.  
  1700. %% eecchhoo ''ddoonn''\\''''tt ddoo tthhaatt;; ttyyppee ''\\''''rrmm --rrff \\**''\\'''',, wwiitthh aa \\ bbeeffoorree tthhee **..''
  1701. ddoonn''tt ddoo tthhaatt;; ttyyppee ''rrmm --rrff \\**'',, wwiitthh aa \\ bbeeffoorree tthhee **..
  1702.  
  1703. Let's  say  you want to create an alias to do this eecchhoo com-
  1704. mand.  This can be done by recalling the line  with  _^_P  and
  1705. pressing _E_S_C_-_' again:
  1706.  
  1707. %% ''eecchhoo ''\\''''ddoonn''\\''''\\''\\''''''\\''''tt ddoo tthhaatt;; ttyyppee ''\\''''\\''\\''''''\\''''rrmm --rrff
  1708. \\**''\\''''\\''\\''''''\\'''',, wwiitthh aa \\ bbeeffoorree tthhee **..''\\''''''
  1709.  
  1710. and then move to the beginning and add the command to create
  1711.  
  1712.  
  1713.  
  1714.  
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720.                             -27-
  1721.  
  1722.  
  1723. an alias.
  1724.  
  1725. %% aalliiaass zzooooff==''eecchhoo ''\\''''ddoonn''\\''''\\''\\''''''\\''''tt ddoo tthhaatt;; ttyyppee ''\\''''\\''\\''''''\\''''rrmm
  1726. --rrff \\**''\\''''\\''\\''''''\\'''',, wwiitthh aa \\ bbeeffoorree tthhee **..''\\''''''
  1727. %% zzooooff
  1728. ddoonn''tt ddoo tthhaatt;; ttyyppee ''rrmm --rrff \\**'',, wwiitthh aa \\ bbeeffoorree tthhee **..
  1729.  
  1730. If one of these fancy editor commands changes  your  command
  1731. line  in a way you did not intend, you can undo changes with
  1732. ^^__, if you can get it out of your keyboard, or ^^XX^^UU,  other-
  1733. wise.
  1734.  
  1735. Another use of the editor is to edit the value of variables.
  1736. For example, an easy way to change your path is to  use  the
  1737. vvaarreedd command:
  1738.  
  1739. %% vvaarreedd PPAATTHH
  1740. >> //uu//ppffaallssttaadd//ssccrr:://uu//ppffaallssttaadd//bbiinn//ssuunn44:://uu//mmaarruucchhcckk//ssccrr:://uu//ssuubbbbaarraaoo//bbiinn:://uu//mmaarruucc
  1741. hhcckk//bbiinn:://uu//ssuubbbbaarraaoo//ssccrriippttss:://uussrr//pprriinncceettoonn//bbiinn:://uussrr//uuccbb:://uussrr//bbiinn:://bbiinn:://uussrr//hhoosstt
  1742. ss:://uussrr//pprriinncceettoonn//bbiinn//XX1111:://..//uussrr//llaanngg:://..//uussrr//eettcc:://..//eettcc
  1743.  
  1744. You  can now edit the path.  When you press return, the con-
  1745. tents of the edit buffer will be assigned to PPAATTHH.
  1746.  
  1747. CCoommpplleettiioonn
  1748.  
  1749. Another great zzsshh feature is completion.  If  you  hit  _T_A_B,
  1750. zzsshh  will  complete  all  kinds  of stuff.  Like commands or
  1751. filenames:
  1752.  
  1753. %% ccoommpp_T_A_B
  1754. %% ccoommpprreessss __
  1755.  
  1756. %% llss nniicc_T_A_B
  1757. %% llss nniicceeccoolloorrss __
  1758.  
  1759. %% llss //uussrr//pprr_T_A_B
  1760. %% llss //uussrr//pprriinncceettoonn//__
  1761.  
  1762. %% llss --ll ==ccoomm_T_A_B
  1763. %% llss --ll ==ccoommpprreessss __
  1764.  
  1765. If the completion is ambiguous, the editor  will  beep.   If
  1766. you  find  this annoying, you can set the _N_O_L_I_S_T_B_E_E_P option.
  1767. Completion can even be done in the middle of words.  To  use
  1768. this, you will have to set the _C_O_M_P_L_E_T_E_I_N_W_O_R_D option:
  1769.  
  1770. %% sseettoopptt ccoommpplleetteeiinnwwoorrdd
  1771. %% llss //uussrr//pptt__oonn_T_A_B
  1772. %% llss //uussrr//pprriinncceett__oonn//
  1773. %% sseettoopptt aallwwaayyssttooeenndd
  1774. %% llss //uussrr//pptt__oonn_T_A_B
  1775. %% llss //uussrr//pprriinncceettoonn//__
  1776.  
  1777.  
  1778.  
  1779.  
  1780.  
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786.                             -28-
  1787.  
  1788.  
  1789. You can list possible completions by pressing _^_D:
  1790.  
  1791. %% llss //vvmmuu_T_A_B _-_-_b_e_e_p_-_-
  1792. %% llss //vvmmuunniixx__
  1793. %% llss //vvmmuunniixx_^_D
  1794. vvmmuunniixx                    vvmmuunniixx..oolldd
  1795. vvmmuunniixx..nneeww..kkeerrnneellmmaapp..oolldd  vvmmuunniixx..oorrgg
  1796.  
  1797. Or, you could just set the _A_U_T_O_L_I_S_T option:
  1798.  
  1799. %% sseettoopptt aauuttoolliisstt
  1800. %% llss //vvmmuu_T_A_B _-_-_b_e_e_p_-_-
  1801. vvmmuunniixx                    vvmmuunniixx..oolldd
  1802. vvmmuunniixx..nneeww..kkeerrnneellmmaapp..oolldd  vvmmuunniixx..oorrgg
  1803. %% llss //vvmmuunniixx__
  1804.  
  1805. If  you  like  to see the types of the files in these lists,
  1806. like in llss --FF, you can set the _L_I_S_T_T_Y_P_E_S  option.   Together
  1807. with  _A_U_T_O_L_I_S_T  you  can  use _L_I_S_T_A_M_B_I_G_U_O_U_S.  This will only
  1808. list the possibilities if there is no  unambiguous  part  to
  1809. add:
  1810.  
  1811. %% sseettoopptt lliissttaammbbiigguuoouuss
  1812. %% llss //vvmmuu_T_A_B _-_-_b_e_e_p_-_-
  1813. %% llss //vvmmuunniixx___T_A_B _-_-_b_e_e_p_-_-
  1814. vvmmuunniixx                    vvmmuunniixx..oolldd
  1815. vvmmuunniixx..nneeww..kkeerrnneellmmaapp..oolldd  vvmmuunniixx..oorrgg
  1816.  
  1817. If  you  don't  want several of these listings to scroll the
  1818. screen so much, the _A_L_W_A_Y_S_L_A_S_T_P_R_O_M_P_T option is  useful.   If
  1819. set,  you  can  continue  to edit the line you were editing,
  1820. with the completion listing appearing beneath it.
  1821.  
  1822. Another interesting option is  _M_E_N_U_C_O_M_P_L_E_T_E.   This  affects
  1823. the way _T_A_B works.  Let's look at the //vvmmuunniixx example again:
  1824.  
  1825. %% sseettoopptt mmeennuuccoommpplleettee
  1826. %% llss //vvmmuu_T_A_B
  1827. %% llss //vvmmuunniixx_T_A_B
  1828. %% llss //vvmmuunniixx..nneeww..kkeerrnneellmmaapp..oolldd_T_A_B
  1829. %% llss //vvmmuunniixx..oolldd__
  1830.  
  1831. Each time you press _T_A_B, it displays the next possible  com-
  1832. pletion.   In  this  way, you can cycle through the possible
  1833. completions until you find the one you want.
  1834.  
  1835. The _A_U_T_O_M_E_N_U option makes a  nice  compromise  between  this
  1836. method  of  completion  and  the regular method.  If you set
  1837. this option, pressing _T_A_B  once  completes  the  unambiguous
  1838. part  normally,  pressing  the  _T_A_B  key repeatedly after an
  1839. ambiguous completion will cycle through the possible comple-
  1840. tions.
  1841.  
  1842.  
  1843.  
  1844.  
  1845.  
  1846.  
  1847.  
  1848.  
  1849.  
  1850.  
  1851.  
  1852.                             -29-
  1853.  
  1854.  
  1855. Another option you could set is _R_E_C_E_X_A_C_T, which causes exact
  1856. matches to be accepted, even if  there  are  other  possible
  1857. completions:
  1858.  
  1859. %% sseettoopptt rreecceexxaacctt
  1860. %% llss //vvmmuu_T_A_B _-_-_b_e_e_p_-_-
  1861. vvmmuunniixx                    vvmmuunniixx..oolldd
  1862. vvmmuunniixx..nneeww..kkeerrnneellmmaapp..oolldd  vvmmuunniixx..oorrgg
  1863. %% llss //vvmmuunniixx___T_A_B
  1864. %% llss //vvmmuunniixx __
  1865.  
  1866. To facilitate the typing of pathnames, a slash will be added
  1867. whenever a directory is  completed.   Some  computers  don't
  1868. like the spurious slashes at the end of directory names.  In
  1869. that case, the _A_U_T_O_R_E_M_O_V_E_S_L_A_S_H option comes to  rescue.   It
  1870. will  remove  these  slashes when you type a space or return
  1871. after them.
  1872.  
  1873. The _f_i_g_n_o_r_e variable lists suffixes of files to ignore  dur-
  1874. ing completion.
  1875.  
  1876. %% llss ffoooo_T_A_B _-_-_b_e_e_p_-_-
  1877. ffooooffiillee..cc  ffooooffiillee..oo
  1878. %% ffiiggnnoorree==(( ..oo \\~~ ..bbaakk ..jjuunnkk ))
  1879. %% llss ffoooo_T_A_B
  1880. %% llss ffooooffiillee..cc __
  1881.  
  1882. Since ffooooffiillee..oo has a suffix that is in the ffiiggnnoorree list, it
  1883. was not considered a possible completion of ffoooo.
  1884.  
  1885. Username completion is also supported:
  1886.  
  1887. %% llss ~~ppffaall_T_A_B
  1888. %% llss ~~ppffaallssttaadd//__
  1889.  
  1890. and parameter name completion:
  1891.  
  1892. %% eecchhoo $$OORRGG_T_A_B
  1893. %% eecchhoo $$OORRGGAANNIIZZAATTIIOONN __
  1894. %% eecchhoo $${{OORRGG_T_A_B
  1895. %% eecchhoo $${{OORRGGAANNIIZZAATTIIOONN __
  1896.  
  1897. Note that in the last example a space  is  added  after  the
  1898. completion  as  usual.   But  if  you want to add a colon or
  1899. closing brace, you probably don't  want  this  extra  space.
  1900. Setting  the  _A_U_T_O_P_A_R_A_M_K_E_Y_S option will automatically remove
  1901. this space if you type a colon or closing brace after such a
  1902. completion.
  1903.  
  1904. There is also option completion:
  1905.  
  1906. %% sseettoopptt nnooccll_T_A_B
  1907. %% sseettoopptt nnoocclloobbbbeerr __
  1908.  
  1909.  
  1910.  
  1911.  
  1912.  
  1913.  
  1914.  
  1915.  
  1916.  
  1917.  
  1918.                             -30-
  1919.  
  1920.  
  1921. and binding completion:
  1922.  
  1923. %% bbiinnddkkeeyy ''^^XX^^XX'' ppuu_T_A_B
  1924. %% bbiinnddkkeeyy ''^^XX^^XX'' ppuusshh--lliinnee __
  1925.  
  1926. The  ccoommppccttll  command  is  used to control completion of the
  1927. arguments of specific commands.   For  example,  to  specify
  1928. that  certain commands take other commands as arguments, you
  1929. use ccoommppccttll --cc:
  1930.  
  1931. %% ccoommppccttll --cc mmaann nnoohhuupp
  1932. %% mmaann uupptt_T_A_B
  1933. %% mmaann uuppttiimmee __
  1934.  
  1935. To specify that a command  should  complete  filenames,  you
  1936. should use ccoommppccttll --ff.  This is the default.  It can be com-
  1937. bined with --cc, as well.
  1938.  
  1939. %% ccoommppccttll --ccff eecchhoo
  1940. %% eecchhoo uupptt_T_A_B
  1941. %% eecchhoo uuppttiimmee __
  1942.  
  1943. %% eecchhoo ffoo_T_A_B
  1944. %% eecchhoo ffoooo..cc
  1945.  
  1946. Similarly, use --oo to specify options, --vv  to  specify  vari-
  1947. ables, and --bb to specify bindings.
  1948.  
  1949. %% ccoommppccttll --oo sseettoopptt uunnsseettoopptt
  1950. %% ccoommppccttll --vv ttyyppeesseett vvaarreedd uunnsseett eexxppoorrtt
  1951. %% ccoommppccttll --bb bbiinnddkkeeyy
  1952.  
  1953. You  can also use --kk to specify a custom list of keywords to
  1954. use in completion.  After the --kk comes either the name of an
  1955. array or a literal array to take completions from.
  1956.  
  1957. %% ffttpphhoossttss==((ffttpp..uuuu..nneett wwuuaarrcchhiivvee..wwuussttll..eedduu))
  1958. %% ccoommppccttll --kk ffttpphhoossttss ffttpp
  1959. %% ffttpp wwuu_T_A_B
  1960. %% ffttpp wwuuaarrcchhiivvee..wwuussttll..eedduu __
  1961.  
  1962. %% ccoommppccttll --kk ''((ccppiirraazzzzii ssuubbbbaarraaoo ssuukktthhnnkkrr))'' mmaaiill ffiinnggeerr
  1963. %% ffiinnggeerr ccpp_T_A_B
  1964. %% ffiinnggeerr ccppiirraazzzzii __
  1965.  
  1966. To  better  specify the files to complete for a command, use
  1967. the --gg option which takes any glob pattern as  an  argument.
  1968. Be sure to quote the glob patterns as otherwise they will be
  1969. expanded when the ccoommppccttll command is run.
  1970.  
  1971. %% llss
  1972. lleetttteerr..tteexx  lleetttteerr..ddvvii  lleetttteerr..aauuxx  lleetttteerr..lloogg  lleetttteerr..ttoocc
  1973. %% ccoommppccttll --gg ''**..tteexx'' llaatteexx
  1974. %% ccoommppccttll --gg ''**..ddvvii'' xxddvvii ddvviippss
  1975.  
  1976.  
  1977.  
  1978.  
  1979.  
  1980.  
  1981.  
  1982.  
  1983.  
  1984.                             -31-
  1985.  
  1986.  
  1987. %% llaatteexx ll_T_A_B
  1988. %% llaatteexx lleetttteerr..tteexx __
  1989. %% xxddvvii ll_T_A_B
  1990. %% xxddvvii lleetttteerr..ddvvii __
  1991.  
  1992. Glob patterns can include qualifiers within parentheses.  To
  1993. rmdir  only  directories  and cd to directories and symbolic
  1994. links pointing to them:
  1995.  
  1996. %% ccoommppccttll --gg ''**((--//))'' ccdd
  1997. %% ccoommppccttll --gg ''**((//))'' rrmmddiirr
  1998.  
  1999. RCS users like to run commands on files which are not in the
  2000. current  directory,  but  in the RCS subdirectory where they
  2001. all get ,,vv suffixes.  They might like to use
  2002.  
  2003. %% ccoommppccttll --gg ''RRCCSS//**((::tt::ss//\\,,vv////))'' ccoo rrlloogg rrccss
  2004. %% llss RRCCSS
  2005. bbuuiillttiinn..cc,,vv  lleexx..cc,,vv      zzllee__mmaaiinn..cc,,vv
  2006. %% rrlloogg bbuu_T_A_B
  2007. %% rrlloogg bbuuiillttiinn..cc __
  2008.  
  2009. The ::tt modifier keeps only the last part of the pathname and
  2010. the ::ss//\\,,vv//// will replace any ,,vv by nothing.
  2011.  
  2012. The  --ss  flag  is similar to --gg, but it uses all expansions,
  2013. instead of just globbing, like  brace  expansion,  parameter
  2014. substitution and command substitution.
  2015.  
  2016. %% ccoommppccttll --ss ''$$((sseettoopptt))'' uunnsseettoopptt
  2017.  
  2018. will  only  complete  options  which  are actually set to be
  2019. arguments to uunnsseettoopptt.
  2020.  
  2021. Sometimes a command takes another command as  its  argument.
  2022. You  can tell zzsshh to complete commands as the first argument
  2023. to such a command and then use the completion method of  the
  2024. second  command.  The --ll flag with a null-string argument is
  2025. used for this.
  2026.  
  2027. %% ccoommppccttll --ll '''' nnoohhuupp eexxeecc
  2028. %% nnoohhuupp ccoommpp_T_A_B
  2029. %% nnoohhuupp ccoommpprreessss __
  2030. %% nnoohhuupp ccoommpprreessss ffiill_T_A_B
  2031. %% nnoohhuupp ccoommpprreessss ffiilleennaammee __
  2032.  
  2033. Sometimes you would like to run really complicated  commands
  2034. to  find out what the possible completions are.  To do this,
  2035. you can specify a shell function  to  be  called  that  will
  2036. assign  the possible completions to a variable called reply.
  2037. Note that this variable must be an  array.   Here's  another
  2038. (much slower) way to get the completions for ccoo and friends:
  2039.  
  2040. %% ffuunnccttiioonn ggeettrrccss {{
  2041.  
  2042.  
  2043.  
  2044.  
  2045.  
  2046.  
  2047.  
  2048.  
  2049.  
  2050.                             -32-
  2051.  
  2052.  
  2053. >> rreeppllyy==(())
  2054. >> ffoorr ii iinn RRCCSS//**
  2055. >>   ddoo
  2056. >>   rreeppllyy==(($$rreeppllyy[[**]] $$((bbaasseennaammee $$ii ,,vv))))
  2057. >>   ddoonnee
  2058. >> }}
  2059. %% ccoommppccttll --KK ggeettrrccss ccoo rrlloogg rrccss
  2060.  
  2061. Some command arguments use a prefix that is not  a  part  of
  2062. the  things  to  complete.  The kill builtin command takes a
  2063. signal name after a --.  To make such a prefix be ignored  in
  2064. the completion process, you can use the --PP flag.
  2065.  
  2066. %% ccoommppccttll --PP -- --kk ssiiggnnaallss kkiillll
  2067. %% kkiillll --HH_T_A_B
  2068. %% kkiillll --HHUUPP __
  2069.  
  2070. TeX  is  usually run on files ending in ..tteexx, but also some-
  2071. times on other files.  It is somewhat  annoying  to  specify
  2072. that the arguments of TeX should end in ..tteexx and then not be
  2073. able to complete these other files.  Therefore you can spec-
  2074. ify  things like "Complete to files ending in ..tteexx if avail-
  2075. able, otherwise complete to any filename.".   This  is  done
  2076. with _x_o_red completion:
  2077.  
  2078. %% ccoommppccttll --gg ''**..tteexx'' ++ --ff tteexx
  2079.  
  2080. The  ++  tells  the  editor  to only take the next thing into
  2081. account if the current one doesn't generate any matches.  If
  2082. you have not changed the default completion, the above exam-
  2083. ple is in fact equivalent to
  2084.  
  2085. %% ccoommppccttll --gg ''**..tteexx'' ++ tteexx
  2086.  
  2087. as a lone ++ at the  end  is  equivalent  to  specifying  the
  2088. default  completion after the ++.  This form of completion is
  2089. also frequently used if you want to run some command only on
  2090. a  certain type of files, but not necessarily in the current
  2091. directory.  In this case you  will  want  to  complete  both
  2092. files of this type and directories.  Depending on your pref-
  2093. erences you can use either of
  2094.  
  2095. %% ccoommppccttll --gg ''**..ppss'' ++ --gg ''**((--//))'' gghhoossttvviieeww
  2096. %% ccoommppccttll --gg ''**..ppss **((--//))'' gghhoossttvviieeww
  2097.  
  2098. where the first one will only complete directories (and sym-
  2099. bolic  links  pointing to directories) if no postscript file
  2100. matches the already typed part of the argument.
  2101.  
  2102. EExxtteennddeedd ccoommpplleettiioonn
  2103.  
  2104. If you play with completion, you will soon notice  that  you
  2105. would  like  to  specify what to complete, depending on what
  2106. flags you give to the command  and  where  you  are  on  the
  2107.  
  2108.  
  2109.  
  2110.  
  2111.  
  2112.  
  2113.  
  2114.  
  2115.  
  2116.                             -33-
  2117.  
  2118.  
  2119. command  line.   For example, a command could take any file-
  2120. name argument after a --ff flag, a username after  a  --uu  flag
  2121. and an executable after a --xx flag.  This section will intro-
  2122. duce you to the ways to specify these things.  To many  peo-
  2123. ple it seems rather difficult at first, but taking the trou-
  2124. ble to understand it can save you lots of typing in the end.
  2125. Even  I  keep being surprised when zzsshh manages to complete a
  2126. small or even empty prefix to the  right  file  in  a  large
  2127. directory.
  2128.  
  2129. To  tell  zzsshh  about  these  kinds  of  completion,  you use
  2130. "extended completion" by specifying the --xx flag to  compctl.
  2131. The  --xx flag takes a list of patterns/flags pairs.  The pat-
  2132. terns specify when to complete and the flags  specify  what.
  2133. The  flags  are  simply those mentioned above, like --ff or --gg
  2134. _g_l_o_b _p_a_t_t_e_r_n.
  2135.  
  2136. As an example, the rr[[_s_t_r_i_n_g_1,,_s_t_r_i_n_g_2]] pattern matches if the
  2137. cursor  is  after  something  that  starts  with _s_t_r_i_n_g_1 and
  2138. before something that starts with _s_t_r_i_n_g_2.  The  _s_t_r_i_n_g_2  is
  2139. often  something  that  you do not want to match anything at
  2140. all.
  2141.  
  2142. %% llss
  2143. ffoooo11   bbaarr11   ffoooo..ZZ  bbaarr..ZZ
  2144. %% ccoommppccttll --gg ''^^**..ZZ'' --xx ''rr[[--dd,,------]]'' --gg ''**..ZZ'' ---- ccoommpprreessss
  2145. %% ccoommpprreessss ff_T_A_B
  2146. %% ccoommpprreessss ffoooo11 __
  2147. %% ccoommpprreessss --dd ff_T_A_B
  2148. %% ccoommpprreessss --dd ffoooo..ZZ __
  2149.  
  2150. In the above example, if the cursor is after the --dd the pat-
  2151. tern  will match and therefore zzsshh uses the --gg **..ZZ flag that
  2152. will only complete files ending in  ..ZZ.   Otherwise,  if  no
  2153. pattern  matches, it will use the flags before the --xx and in
  2154. this case complete every file that does not end in ..ZZ.
  2155.  
  2156. The ss[[_s_t_r_i_n_g]] pattern matches if  the  current  word  starts
  2157. with _s_t_r_i_n_g.  The _s_t_r_i_n_g itself is not considered to be part
  2158. of the completion.
  2159.  
  2160. %% ccoommppccttll --xx ''ss[[--]]'' --kk ssiiggnnaallss ---- kkiillll
  2161. %% kkiillll --HH_T_A_B
  2162. %% kkiillll --HHUUPP __
  2163.  
  2164. The ttaarr command takes a tar file as an argument after the --ff
  2165. option.  The cc[[_o_f_f_s_e_t,,_s_t_r_i_n_g]] pattern matches if the word in
  2166. position _o_f_f_s_e_t relative to  the  current  word  is  _s_t_r_i_n_g.
  2167. More  in particular, if _o_f_f_s_e_t is -1, it matches if the pre-
  2168. vious word is _s_t_r_i_n_g.  This suggests
  2169.  
  2170. %% ccoommppccttll --ff --xx ''cc[[--11,,--ff]]'' --gg ''**..ttaarr'' ---- ttaarr
  2171.  
  2172. But this is not enough.  The --ff option could be the last  of
  2173.  
  2174.  
  2175.  
  2176.  
  2177.  
  2178.  
  2179.  
  2180.  
  2181.  
  2182.                             -34-
  2183.  
  2184.  
  2185. a  longer  string  of  options.   CC[[...,,...]]  is  just  like
  2186. cc[[...,,...]], except that it uses glob-like  pattern  matching
  2187. for _s_t_r_i_n_g.  So
  2188.  
  2189. %% ccoommppccttll --ff --xx ''CC[[--11,,--**ff]]'' --gg ''**..ttaarr'' ---- ttaarr
  2190.  
  2191. will complete tar files after any option string ending in an
  2192. ff.  But we'd like even more.  Old versions of tar  used  all
  2193. options  as  the first argument, but without the minus sign.
  2194. This might be inconsistent with option usage  in  all  other
  2195. commands,  but  it  is  still supported by newer versions of
  2196. ttaarr.  So we would also like to complete  tar  files  if  the
  2197. first argument ends in an ff and we're right behind it.
  2198.  
  2199. We  can  `and'  patterns  by putting them next to each other
  2200. with a space between  them.   We  can  `or'  these  sets  by
  2201. putting  comma's  between  them.  We will also need some new
  2202. patterns.  pp[[_n_u_m]] will match if the  current  argument  (the
  2203. one    to    be    completed)   is   the   _n_u_mth   argument.
  2204. WW[[_i_n_d_e_x,,_p_a_t_t_e_r_n]] will match if the argument in  place  _i_n_d_e_x
  2205. matches the _p_a_t_t_e_r_n.  This gives us
  2206.  
  2207. %% ccoommppccttll --ff --xx ''CC[[--11,,--**ff]] ,, WW[[11,,**ff]] pp[[22]]'' --gg ''**..ttaarr'' ---- ttaarr
  2208.  
  2209. In  words: If the previous argument is an option string that
  2210. ends in an ff, or the first argument ended in an ff and it  is
  2211. now the second argument, then complete only filenames ending
  2212. in ..ttaarr.
  2213.  
  2214. All the above examples used only one set  of  patterns  with
  2215. one  completion  flag.   You  can  use several of these pat-
  2216. tern/flag pairs separated by a --.  The first  matching  pat-
  2217. tern  will  be used.  Suppose you have a version of ttaarr that
  2218. supports compressed files by using a --ZZ option.  Leaving the
  2219. old tar syntax aside for a moment, we would like to complete
  2220. files ending in ..ttaarr..ZZ if a --ZZ  option  has  been  used  and
  2221. files  ending  in  ..ttaarr  otherwise, all this only after a --ff
  2222. flag.  Again, the --ZZ can be alone or it can  be  part  of  a
  2223. longer  option  string,  perhaps  the same as that of the --ff
  2224. flag.  Here's how to do it; note the backslash and the  sec-
  2225. ondary prompt which are not part of the ccoommppccttll command.
  2226.  
  2227. %% ccoommppccttll --ff --xx ''CC[[--11,,--**ZZ**ff]] ,, RR[[--**ZZ**,,------]] CC[[--11,,--**ff]]'' --gg ''**..ttaarr..ZZ'' -- \\
  2228. >> ''CC[[--11,,--**ff]]'' --gg ''**..ttaarr'' ---- ttaarr
  2229.  
  2230. The first pattern set tells us to match if either the previ-
  2231. ous argument was an option string including a ZZ  and  ending
  2232. in an ff or there was an option string with a ZZ somewhere and
  2233. the previous word was any option string ending in an ff.   If
  2234. this  is  the  case, we need a compressed tar file.  Only if
  2235. this is not the case the second pattern set will be  consid-
  2236. ered.    By  the  way,  RR[[_p_a_t_t_e_r_n_1,,_p_a_t_t_e_r_n_2]]  is  just  like
  2237. rr[[...,,...]] except that it uses pattern matching  with  shell
  2238. metacharacters instead of just strings.
  2239.  
  2240.  
  2241.  
  2242.  
  2243.  
  2244.  
  2245.  
  2246.  
  2247.  
  2248.                             -35-
  2249.  
  2250.  
  2251. You  will have noticed the ---- before the command name.  This
  2252. ends the list of pattern/flag pairs of --xx.   It  is  usually
  2253. used  just  before the command name, but you can also use an
  2254. extended completion as one part of a list of  xored  comple-
  2255. tions, in which case the ---- appears just before one of the ++
  2256. signs.
  2257.  
  2258. Note the difference between  using  extended  completion  as
  2259. part of a list of xored completions as in
  2260.  
  2261. %% llss
  2262. ffoooo  bbaarr
  2263. %% ccoommppccttll --xx ''rr[[--dd,,------]]'' --gg ''**..ZZ'' ---- ++ --gg ''^^**..ZZ'' ccoommpprreessss
  2264. %% ccoommpprreessss --dd ff_T_A_B
  2265. %% ccoommpprreessss --dd ffoooo __
  2266.  
  2267. and specifying something before the --xx as in
  2268.  
  2269. %% ccoommppccttll --gg ''^^**..ZZ'' --xx ''rr[[--dd,,------]]'' --gg ''**..ZZ'' ---- ccoommpprreessss
  2270. %% ccoommpprreessss --dd ff_T_A_B
  2271. %% ccoommpprreessss --dd ff__
  2272.  
  2273. In  the first case, the alternative glob pattern (^^**..ZZ) will
  2274. be used if the first part does  not  generate  any  possible
  2275. completions,  while  in the second case the alternative glob
  2276. pattern will only be used  if  the  rr[[...]]  pattern  doesn't
  2277. match.
  2278.  
  2279. BBiinnddiinnggss
  2280.  
  2281. Each  of  the  editor  commands  we have seen was actually a
  2282. function bound by default to a certain key.  The real  names
  2283. of the commands are:
  2284.  
  2285. eexxppaanndd--oorr--ccoommpplleettee   _T_A_B
  2286. ppuusshh--lliinnee            _E_S_C_-_Q
  2287. rruunn--hheellpp             _E_S_C_-_H
  2288. aacccceepptt--aanndd--hhoolldd      _E_S_C_-_A
  2289. qquuoottee--lliinnee           _E_S_C_-_'
  2290.  
  2291. These  bindings  are arbitrary; you could change them if you
  2292. want.  For example, to bind aacccceepptt--lliinnee to _^_Z:
  2293.  
  2294. %% bbiinnddkkeeyy ''^^ZZ'' aacccceepptt--lliinnee
  2295.  
  2296. Another idea would be to bind the delete key to ddeelleettee--cchhaarr;
  2297. this might be convenient if you use _^_H for backspace.
  2298.  
  2299. %% bbiinnddkkeeyy ''^^??'' ddeelleettee--cchhaarr
  2300.  
  2301. Or, you could bind _^_X_^_H to rruunn--hheellpp:
  2302.  
  2303. %% bbiinnddkkeeyy ''^^XX^^HH'' rruunn--hheellpp
  2304.  
  2305.  
  2306.  
  2307.  
  2308.  
  2309.  
  2310.  
  2311.  
  2312.  
  2313.  
  2314.                             -36-
  2315.  
  2316.  
  2317. Other examples:
  2318.  
  2319. %% bbiinnddkkeeyy ''^^XX^^ZZ'' uunniivveerrssaall--aarrgguummeenntt
  2320. %% bbiinnddkkeeyy '' '' mmaaggiicc--ssppaaccee
  2321. %% bbiinnddkkeeyy --ss ''^^TT'' ''uuppttiimmee
  2322. >> ''
  2323. %% bbiinnddkkeeyy ''^^QQ'' ppuusshh--lliinnee--oorr--eeddiitt
  2324.  
  2325. uunniivveerrssaall--aarrgguummeenntt  multiplies  the next command by 4.  Thus
  2326. _^_X_^_Z_^_W might delete the last four words on the line.  If you
  2327. bind  space to mmaaggiicc--ssppaaccee, then csh-style history expansion
  2328. is done on the line whenever you press the space bar.
  2329.  
  2330. Something that often happens is that I am typing a multiline
  2331. command  and discover an error in one of the previous lines.
  2332. In this case, ppuusshh--lliinnee--oorr--eeddiitt will put the  entire  multi-
  2333. line  construct  into the editor buffer.  If there is only a
  2334. single line, it is equivalent to ppuusshh--lliinnee.
  2335.  
  2336. The --ss flag to bbiinnddkkeeyy specifies that you  are  binding  the
  2337. key  to  a  string,  not  a  command.   Thus bbiinnddkkeeyy --ss ''^^TT''
  2338. ''uuppttiimmee\\nn'' lets you VMS lovers get the load average whenever
  2339. you press _^_T.
  2340.  
  2341. If  you  have a NeXT keyboard, the one with the || and \\ keys
  2342. very inconveniently placed, the following bindings may  come
  2343. in handy:
  2344.  
  2345. %% bbiinnddkkeeyy --ss ''\\ee//'' ''\\\\''
  2346. %% bbiinnddkkeeyy --ss ''\\ee=='' ''||''
  2347.  
  2348. Now  you can type _A_L_T_-_/ to get a backslash, and _A_L_T_-_= to get
  2349. a vertical bar.  This only  works  inside  zzsshh,  of  course;
  2350. bbiinnddkkeeyy  has  no  effect  on the key mappings inside ttaallkk or
  2351. mmaaiill, etc.
  2352.  
  2353. Some people like to bind ^^SS and ^^QQ to editor commands.  Just
  2354. binding these has no effect, as the terminal will catch them
  2355. and use them for flow control.  You could unset them as stop
  2356. and  start characters, but most people like to use these for
  2357. external commands.  The solution is to set the _N_O_F_L_O_W_C_O_N_T_R_O_L
  2358. option.   This  will  allow  you  to bind the start and stop
  2359. characters to editor commands, while retaining their  normal
  2360. use for external commands.
  2361.  
  2362. PPaarraammeetteerr SSuubbssttiittuuttiioonn
  2363.  
  2364. In zzsshh, parameters are set like this:
  2365.  
  2366. %% ffoooo==bbaarr
  2367. %% eecchhoo $$ffoooo
  2368. bbaarr
  2369.  
  2370. Spaces before or after the == are frowned upon:
  2371.  
  2372.  
  2373.  
  2374.  
  2375.  
  2376.  
  2377.  
  2378.  
  2379.  
  2380.                             -37-
  2381.  
  2382.  
  2383. %% ffoooo == bbaarr
  2384. zzsshh:: ccoommmmaanndd nnoott ffoouunndd:: ffoooo
  2385.  
  2386. Also, sseett doesn't work for setting parameters:
  2387.  
  2388. %% sseett ffoooo==bbaarr
  2389. %% sseett ffoooo == bbaarr
  2390. %% eecchhoo $$ffoooo
  2391.  
  2392. %%
  2393.  
  2394. Note  that  no  error  message was printed.  This is because
  2395. both of these commands were perfectly valid; the sseett builtin
  2396. assigns  its arguments to the _p_o_s_i_t_i_o_n_a_l _p_a_r_a_m_e_t_e_r_s ($$11, $$22,
  2397. etc.).
  2398.  
  2399. %% sseett ffoooo==bbaarr
  2400. %% eecchhoo $$11
  2401. ffoooo==bbaarr
  2402. %% sseett ffoooo == bbaarr
  2403. %% eecchhoo $$33 $$22
  2404. bbaarr ==
  2405.  
  2406. If you're really intent on using the csh  syntax,  define  a
  2407. function like this:
  2408.  
  2409. %% sseett (()) {{
  2410. >>    eevvaall ""$$11$$22$$33""
  2411. >> }}
  2412. %% sseett ffoooo == bbaarr
  2413. %% sseett ffuuuu==bbrrrrrr
  2414. %% eecchhoo $$ffoooo $$ffuuuu
  2415. bbaarr bbrrrrrr
  2416.  
  2417. But  then,  of  course  you  can't  use the form of sseett with
  2418. options, like sseett --FF (which turns off filename  generation).
  2419. Also,  the  sseett command by itself won't list all the parame-
  2420. ters like it should.  To get around that  you  need  a  ccaassee
  2421. statement:
  2422.  
  2423. %% sseett (()) {{
  2424. >>    ccaassee $$11 iinn
  2425. >>    --**||++**||'''')) bbuuiillttiinn sseett $$** ;;;;
  2426. >>    **)) eevvaall ""$$11$$22$$33"" ;;;;
  2427. >>    eessaacc
  2428. >> }}
  2429.  
  2430. For the most part, this should make csh users happy.
  2431.  
  2432. The following sh-style operators are supported in zzsshh:
  2433.  
  2434. %% uunnsseett nnuullll
  2435. %% eecchhoo $${{ffoooo--xxxxxx}}
  2436. bbaarr
  2437.  
  2438.  
  2439.  
  2440.  
  2441.  
  2442.  
  2443.  
  2444.  
  2445.  
  2446.                             -38-
  2447.  
  2448.  
  2449. %% eecchhoo $${{nnuullll--xxxxxx}}
  2450. xxxxxx
  2451. %% uunnsseett nnuullll
  2452. %% eecchhoo $${{nnuullll==xxxxxx}}
  2453. xxxxxx
  2454. %% eecchhoo $$nnuullll
  2455. xxxxxx
  2456. %% eecchhoo $${{ffoooo==xxxxxx}}
  2457. bbaarr
  2458. %% eecchhoo $$ffoooo
  2459. bbaarr
  2460. %% uunnsseett nnuullll
  2461. %% eecchhoo $${{nnuullll++sseett}}
  2462.  
  2463. %% eecchhoo $${{ffoooo++sseett}}
  2464. sseett
  2465.  
  2466. Also,  csh-style  :: modifiers may be appended to a parameter
  2467. substitution.
  2468.  
  2469. %% eecchhoo $$PPWWDD
  2470. //hhoommee//lleeaarrnniinngg//ppff//zzsshh//zzsshh22..0000//ssrrcc
  2471. %% eecchhoo $$PPWWDD::hh
  2472. //hhoommee//lleeaarrnniinngg//ppff//zzsshh//zzsshh22..0000
  2473. %% eecchhoo $$PPWWDD::hh::hh
  2474. //hhoommee//lleeaarrnniinngg//ppff//zzsshh
  2475. %% eecchhoo $$PPWWDD::tt
  2476. ssrrcc
  2477. %% nnaammee==ffoooo..cc
  2478. %% eecchhoo $$nnaammee
  2479. ffoooo..cc
  2480. %% eecchhoo $$nnaammee::rr
  2481. ffoooo
  2482. %% eecchhoo $$nnaammee::ee
  2483. cc
  2484.  
  2485. The equivalent constructs in ksh (which are  also  supported
  2486. in zzsshh) are a bit more general and easier to remember.  When
  2487. the shell expands  $${{ffoooo##_p_a_t}},  it  checks  to  see  if  _p_a_t
  2488. matches  a  substring  at the beginning of the value of ffoooo.
  2489. If so, it removes that portion of ffoooo,  using  the  shortest
  2490. possible  match.   With  $${{ffoooo####_p_a_t}},  the  longest possible
  2491. match is removed.  $${{ffoooo%%_p_a_t}}  and  $${{ffoooo%%%%_p_a_t}}  remove  the
  2492. match  from  the end.  Here are the ksh equivalents of the ::
  2493. modifiers:
  2494.  
  2495. %% eecchhoo $${{PPWWDD%%//**}}
  2496. //hhoommee//lleeaarrnniinngg//ppff//zzsshh//zzsshh22..0000
  2497. %% eecchhoo $${{PPWWDD%%//**//**}}
  2498. //hhoommee//lleeaarrnniinngg//ppff//zzsshh
  2499. %% eecchhoo $${{PPWWDD####**//}}
  2500. ssrrcc
  2501. %% eecchhoo $${{nnaammee%%..**}}
  2502. ffoooo
  2503.  
  2504.  
  2505.  
  2506.  
  2507.  
  2508.  
  2509.  
  2510.  
  2511.  
  2512.                             -39-
  2513.  
  2514.  
  2515. %% eecchhoo $${{nnaammee##**..}}
  2516. cc
  2517.  
  2518. zzsshh also has upper/lowercase modifiers:
  2519.  
  2520. %% xxxx==TTeesstt
  2521. %% eecchhoo $$xxxx::uu
  2522. TTEESSTT
  2523. %% eecchhoo $$xxxx::ll
  2524. tteesstt
  2525.  
  2526. and a substitution modifier:
  2527.  
  2528. %% eecchhoo $$nnaammee::ss//ffoooo//bbaarr//
  2529. bbaarr..cc
  2530. %% llss
  2531. ffoooo..cc    ffoooo..hh    ffoooo..oo    ffoooo..pprroo
  2532. %% ffoorr ii iinn ffoooo..**;; mmvv $$ii $$ii::ss//ffoooo//bbaarr//
  2533. %% llss
  2534. bbaarr..cc    bbaarr..hh    bbaarr..oo    bbaarr..pprroo
  2535.  
  2536. There is yet another syntax to  modify  substituted  parame-
  2537. ters.   You  can  add certain modifiers in parentheses after
  2538. the opening brace like:
  2539.  
  2540. $${{((_m_o_d_i_f_i_e_r_s))_p_a_r_a_m_e_t_e_r}}
  2541.  
  2542. For example, oo sorts the words resulting from the expansion:
  2543.  
  2544. %% eecchhoo $${{ppaatthh}}
  2545. //uussrr//bbiinn //uussrr//bbiinn//XX1111 //eettcc
  2546. %% eecchhoo $${{((oo))ppaatthh}}
  2547. //eettcc //uussrr//bbiinn //uussrr//bbiinn//XX1111
  2548.  
  2549. One  possible  source  of confusion is the fact that in zzsshh,
  2550. the result of  parameter  substitution  is  _n_o_t  split  into
  2551. words.  Thus, this will not work:
  2552.  
  2553. %% ssrrccss==''gglloobb..cc eexxeecc..cc iinniitt..cc''
  2554. %% llss $$ssrrccss
  2555. gglloobb..cc eexxeecc..cc iinniitt..cc nnoott ffoouunndd
  2556.  
  2557. This  is considered a feature, not a bug.  If splitting were
  2558. done by default, as it is in most  other  shells,  functions
  2559. like this would not work properly:
  2560.  
  2561. $$ llll (()) {{ llss --FF $$** }}
  2562. $$ llll ''ffuuuu bbaarr''
  2563. ffuuuu nnoott ffoouunndd
  2564. bbaarr nnoott ffoouunndd
  2565.  
  2566. %% llll ''ffuuuu bbaarr''
  2567. ffuuuu bbaarr nnoott ffoouunndd
  2568.  
  2569.  
  2570.  
  2571.  
  2572.  
  2573.  
  2574.  
  2575.  
  2576.  
  2577.  
  2578.                             -40-
  2579.  
  2580.  
  2581. Of  course,  a  hackish  workaround  is available in sh (and
  2582. zzsshh):
  2583.  
  2584. %% sseettoopptt sshhwwoorrddsspplliitt
  2585. %% llll (()) {{ llss --FF ""$$@@"" }}
  2586. %% llll ''ffuuuu bbaarr''
  2587. ffuuuu bbaarr nnoott ffoouunndd
  2588.  
  2589. If you like the sh behaviour, zzsshh can accomodate you:
  2590.  
  2591. %% llss $${{==ssrrccss}}
  2592. eexxeecc..cc  gglloobb..cc  iinniitt..cc
  2593. %% sseettoopptt sshhwwoorrddsspplliitt
  2594. %% llss $$ssrrccss
  2595. eexxeecc..cc  gglloobb..cc  iinniitt..cc
  2596.  
  2597. Another way to get the $$ssrrccss trick to  work  is  to  use  an
  2598. array:
  2599.  
  2600. %% uunnsseett ssrrccss
  2601. %% ssrrccss==(( gglloobb..cc eexxeecc..cc iinniitt..cc ))
  2602. %% llss $$ssrrccss
  2603. eexxeecc..cc  gglloobb..cc  iinniitt..cc
  2604.  
  2605. or an alias:
  2606.  
  2607. %% aalliiaass --gg SSRRCCSS==''eexxeecc..cc gglloobb..cc iinniitt..cc''
  2608. %% llss SSRRCCSS
  2609. eexxeecc..cc  gglloobb..cc  iinniitt..cc
  2610.  
  2611. Another  option  that  modifies parameter expansion is _R_C_E_X_-
  2612. _P_A_N_D_P_A_R_A_M:
  2613.  
  2614. %% eecchhoo ffoooo//$$ssrrccss
  2615. ffoooo//gglloobb..cc eexxeecc..cc iinniitt..cc
  2616. %% sseettoopptt rrcceexxppaannddppaarraamm
  2617. %% eecchhoo ffoooo//$$ssrrccss
  2618. ffoooo//gglloobb..cc ffoooo//eexxeecc..cc ffoooo//iinniitt..cc
  2619. %% eecchhoo ffoooo//$${{^^ssrrccss}}
  2620. ffoooo//gglloobb..cc ffoooo//eexxeecc..cc ffoooo//iinniitt..cc
  2621. %% eecchhoo ffoooo//$$^^ssrrccss
  2622. ffoooo//gglloobb..cc ffoooo//eexxeecc..cc ffoooo//iinniitt..cc
  2623.  
  2624.  
  2625. SShheellll PPaarraammeetteerrss
  2626.  
  2627. The  shell  has  many  predefined  parameters  that  may  be
  2628. accessed.  Here are some examples:
  2629.  
  2630. %% sslleeeepp 1100 &&
  2631. [[11]] 33882200
  2632. %% eecchhoo $$!!
  2633. 33882200
  2634. %% sseett aa bb cc
  2635.  
  2636.  
  2637.  
  2638.  
  2639.  
  2640.  
  2641.  
  2642.  
  2643.  
  2644.                             -41-
  2645.  
  2646.  
  2647. %% eecchhoo $$##
  2648. 33
  2649. %% eecchhoo $$AARRGGCC
  2650. 33
  2651. %% (( eexxiitt 2200 )) ;; eecchhoo $$??
  2652. 2200
  2653. %% ffaallssee;; eecchhoo $$ssttaattuuss
  2654. 11
  2655.  
  2656. ($$?? and $$ssttaattuuss are equivalent.)
  2657.  
  2658. %% eecchhoo $$HHOOSSTT $$HHOOSSTTTTYYPPEE
  2659. ddeennddrriittee ssuunn44
  2660. %% eecchhoo $$UUIIDD $$GGIIDD
  2661. 770011 6600
  2662. %% ccdd //ttmmpp
  2663. %% ccdd //hhoommee
  2664. %% eecchhoo $$PPWWDD $$OOLLDDPPWWDD
  2665. //hhoommee //ttmmpp
  2666. %% llss $$OOLLDDPPWWDD//..ggeettwwdd
  2667. //ttmmpp//..ggeettwwdd
  2668.  
  2669. ~~++ and ~~-- are short for $$PPWWDD and $$OOLLDDPPWWDD, respectively.
  2670.  
  2671. %% llss ~~--//..ggeettwwdd
  2672. //ttmmpp//..ggeettwwdd
  2673. %% llss --dd ~~++//lleeaarrnniinngg
  2674. //hhoommee//lleeaarrnniinngg
  2675. %% eecchhoo $$RRAANNDDOOMM
  2676. 44888800
  2677. %% eecchhoo $$RRAANNDDOOMM
  2678. 1111778855
  2679. %% eecchhoo $$RRAANNDDOOMM
  2680. 22006622
  2681. %% eecchhoo $$TTTTYY
  2682. //ddeevv//ttttyypp44
  2683. %% eecchhoo $$VVEERRSSIIOONN
  2684. zzsshh vv22..0000..0033
  2685. %% eecchhoo $$UUSSEERRNNAAMMEE
  2686. ppff
  2687.  
  2688.  
  2689. The ccddppaatthh variable sets the search path for the ccdd command.
  2690. If you do not specify .. somewhere in the path, it is assumed
  2691. to be the first component.
  2692.  
  2693. %% ccddppaatthh==(( //uussrr ~~ ~~//zzsshh ))
  2694. %% llss //uussrr
  2695. 55bbiinn         ddiicctt         llaanngg         nneett          ssccccss         ssyyss
  2696. 55iinncclluuddee     eettcc          lleeccttoorr       nnsseerrvvee       sseerrvviicceess     ttmmpp
  2697. 55lliibb         eexxppoorrtt       lliibb          ooeedd          sshhaarree        uuccbb
  2698. aaddmm          ggaammeess        llooccaall        oolldd          sskkeell         uuccbbiinncclluuddee
  2699. bbiinn          ggeeaacc         lloosstt++ffoouunndd   ooppeennwwiinn      ssppooooll        uuccbblliibb
  2700. bboooott         hhoossttss        mmaaccssyymmaa__441177  ppaatt          ssrrcc          xxppgg22bbiinn
  2701.  
  2702.  
  2703.  
  2704.  
  2705.  
  2706.  
  2707.  
  2708.  
  2709.  
  2710.                             -42-
  2711.  
  2712.  
  2713. ddeemmoo         iinncclluuddee      mmaann          pprriinncceettoonn    ssttaanndd        xxppgg22iinncclluuddee
  2714. ddiiaagg         kkvvmm          mmddeecc         ppuubb          sswwaapp         xxppgg22lliibb
  2715. %% ccdd ssppooooll
  2716. //uussrr//ssppooooll
  2717. %% ccdd bbiinn
  2718. //uussrr//bbiinn
  2719. %% ccdd ffuunncc
  2720. ~~//ffuunncc
  2721. %% ccdd
  2722. %% ccdd ppuubb
  2723. %% ppwwdd
  2724. //uu//ppffaallssttaadd//ppuubb
  2725. %% llss --dd //uussrr//ppuubb
  2726. //uussrr//ppuubb
  2727.  
  2728. PPAATTHH  and ppaatthh both set the search path for commands.  These
  2729. two variables are equivalent, except that one  is  a  string
  2730. and  one  is an array.  If the user modifies PPAATTHH, the shell
  2731. changes ppaatthh as well, and vice versa.
  2732.  
  2733. %% PPAATTHH==//bbiinn:://uussrr//bbiinn:://ttmmpp::..
  2734. %% eecchhoo $$ppaatthh
  2735. //bbiinn //uussrr//bbiinn //ttmmpp ..
  2736. %% ppaatthh==(( //uussrr//bbiinn .. //uussrr//llooccaall//bbiinn //uussrr//uuccbb ))
  2737. %% eecchhoo $$PPAATTHH
  2738. //uussrr//bbiinn::..:://uussrr//llooccaall//bbiinn:://uussrr//uuccbb
  2739.  
  2740. The same is true of CCDDPPAATTHH and ccddppaatthh:
  2741.  
  2742. %% eecchhoo $$CCDDPPAATTHH
  2743. //uussrr:://uu//ppffaallssttaadd:://uu//ppffaallssttaadd//zzsshh
  2744. %% CCDDPPAATTHH==//uu//ssuubbbbaarraaoo:://uussrr//ssrrcc:://ttmmpp
  2745. %% eecchhoo $$ccddppaatthh
  2746. //uu//ssuubbbbaarraaoo //uussrr//ssrrcc //ttmmpp
  2747.  
  2748. In general, predefined parameters with names in  all  lower-
  2749. case are arrays; assignments to them take the form:
  2750.  
  2751. _n_a_m_e==(( _e_l_e_m ... ))
  2752.  
  2753. Predefined  parameters  with  names  in  all  uppercase  are
  2754. strings.  If there is both an array and a string version  of
  2755. the  same parameter, the string version is a colon-separated
  2756. list, like PPAATTHH.
  2757.  
  2758. HHIISSTTFFIILLEE is the name of the history file, where the  history
  2759. is saved when a shell exits.
  2760.  
  2761. %% zzsshh
  2762. pphhooeenniixx%% HHIISSTTFFIILLEE==//ttmmpp//hhiissttoorryy
  2763. pphhooeenniixx%% SSAAVVEEHHIISSTT==2200
  2764. pphhooeenniixx%% eecchhoo ffoooo
  2765. ffoooo
  2766. pphhooeenniixx%% ddaattee
  2767.  
  2768.  
  2769.  
  2770.  
  2771.  
  2772.  
  2773.  
  2774.  
  2775.  
  2776.                             -43-
  2777.  
  2778.  
  2779. FFrrii MMaayy 2244 0055::3399::3355 EEDDTT 11999911
  2780. pphhooeenniixx%% uuppttiimmee
  2781.   55::3399aamm  uupp 44 ddaayyss,, 2200::0022,,  4400 uusseerrss,,  llooaadd aavveerraaggee:: 22..3300,, 22..2200,, 22..0000
  2782. pphhooeenniixx%% eexxiitt
  2783. %% ccaatt //ttmmpp//hhiissttoorryy
  2784. HHIISSTTFFIILLEE==//ttmmpp//hhiissttoorryy
  2785. SSAAVVEEHHIISSTT==2200
  2786. eecchhoo ffoooo
  2787. ddaattee
  2788. uuppttiimmee
  2789. eexxiitt
  2790. %% HHIISSTTSSIIZZEE==33
  2791. %% hhiissttoorryy
  2792.    2288  rrmm //ttmmpp//hhiissttoorryy
  2793.    2299  HHIISSTTSSIIZZEE==33
  2794.    3300  hhiissttoorryy
  2795.  
  2796. If  you have several incantations of zzsshh running at the same
  2797. time, like when using the  X  window  system,  it  might  be
  2798. preferable  to  append  the  history of each shell to a file
  2799. when a shell exits instead of overwriting the  old  contents
  2800. of  the  file.   You  can  get this behaviour by setting the
  2801. _A_P_P_E_N_D_H_I_S_T_O_R_Y option.
  2802.  
  2803. In zzsshh, if you say
  2804.  
  2805. %% >>ffiillee
  2806.  
  2807. the command ccaatt is normally assumed:
  2808.  
  2809. %% >>ffiillee
  2810. ffoooo!!
  2811. ^^DD
  2812. %% ccaatt ffiillee
  2813. ffoooo!!
  2814.  
  2815. Thus, you can view a file simply by typing:
  2816.  
  2817. %% <<ffiillee
  2818. ffoooo!!
  2819.  
  2820. However, this is not csh or sh compatible.  To correct this,
  2821. change  the  value of the parameter NNUULLLLCCMMDD, which is ccaatt by
  2822. default.
  2823.  
  2824. %% NNUULLLLCCMMDD==::
  2825. %% >>ffiillee
  2826. %% llss --ll ffiillee
  2827. --rrww--rr----rr----  11 ppffaallssttaadd        00 MMaayy 2244 0055::4411 ffiillee
  2828.  
  2829. If NNUULLLLCCMMDD is unset, the shell reports an error if  no  com-
  2830. mand is specified (like csh).
  2831.  
  2832. %% uunnsseett NNUULLLLCCMMDD
  2833.  
  2834.  
  2835.  
  2836.  
  2837.  
  2838.  
  2839.  
  2840.  
  2841.  
  2842.                             -44-
  2843.  
  2844.  
  2845. %% >>ffiillee
  2846. zzsshh:: rreeddiirreeccttiioonn wwiitthh nnoo ccoommmmaanndd
  2847.  
  2848. Actually,  RREEAADDNNUULLLLCCMMDD is used whenever you have a null com-
  2849. mand reading input from a single file.  Thus,  you  can  set
  2850. RREEAADDNNUULLLLCCMMDD  to  mmoorree or lleessss rather than ccaatt.  Also, if you
  2851. set NNUULLLLCCMMDD to :: for sh compatibility, you  can  still  read
  2852. files with << ffiillee if you leave RREEAADDNNUULLLLCCMMDD set to mmoorree.
  2853.  
  2854. PPrroommppttiinngg
  2855.  
  2856. The default prompt for zzsshh is:
  2857.  
  2858. pphhooeenniixx%% eecchhoo $$PPRROOMMPPTT
  2859. %%mm%%##
  2860.  
  2861. The  %%mm  stands  for the short form of the current hostname,
  2862. and the %%## stands for a %% or a ##, depending on  whether  the
  2863. shell  is  running  as root or not.  zzsshh supports many other
  2864. control sequences in the PPRROOMMPPTT variable.
  2865.  
  2866. %% PPRROOMMPPTT==''%%//>> ''
  2867. //uu//ppffaallssttaadd//eettcc//TTeeXX//zzsshh>>
  2868.  
  2869. %% PPRROOMMPPTT==''%%~~>> ''
  2870. ~~//eettcc//TTeeXX//zzsshh>>
  2871.  
  2872. %% PPRROOMMPPTT==''%%hh %%~~>> ''
  2873. 66 ~~//eettcc//TTeeXX//zzsshh>>
  2874.  
  2875. %%hh represents the number of current history event.
  2876.  
  2877. %% PPRROOMMPPTT==''%%hh %%~~ %%MM>> ''
  2878. 1100 ~~//eettcc//TTeeXX//zzsshh aappppllee--gguunnkkiieess..ggnnuu..aaii..mmiitt..eedduu>>
  2879.  
  2880. %% PPRROOMMPPTT==''%%hh %%~~ %%mm>> ''
  2881. 1111 ~~//eettcc//TTeeXX//zzsshh aappppllee--gguunnkkiieess>>
  2882.  
  2883. %% PPRROOMMPPTT==''%%hh %%tt>> ''
  2884. 1122 66::1111aamm>>
  2885.  
  2886. %% PPRROOMMPPTT==''%%nn %%ww ttttyy%%ll>>''
  2887. ppffaallssttaadd FFrrii 2244 ttttyypp00>>
  2888.  
  2889. PPRROOMMPPTT22 is used in multiline commands, like for-loops.   The
  2890. %%__  escape sequence was made especially for this prompt.  It
  2891. is replaced by the kind of command that is being entered.
  2892.  
  2893. %% PPRROOMMPPTT22==''%%__>> ''
  2894. %% ffoorr ii iinn ffoooo bbaarr
  2895. ffoorr>>
  2896.  
  2897. %% eecchhoo ''hhii
  2898. qquuoottee>>
  2899.  
  2900.  
  2901.  
  2902.  
  2903.  
  2904.  
  2905.  
  2906.  
  2907.  
  2908.                             -45-
  2909.  
  2910.  
  2911. Also available is the RRPPRROOMMPPTT parameter.  If  this  is  set,
  2912. the shell puts a prompt on the _r_i_g_h_t side of the screen.
  2913.  
  2914. %% RRPPRROOMMPPTT==''%%tt''
  2915. %%                                                      66::1144aamm
  2916.  
  2917. %% RRPPRROOMMPPTT==''%%~~''
  2918. %%                                               ~~//eettcc//TTeeXX//zzsshh
  2919.  
  2920. %% PPRROOMMPPTT==''%%ll %%TT %%mm[[%%hh]] '' RRPPRROOMMPPTT=='' %%~~''
  2921. pp00 66::1155 pphhooeenniixx[[55]]                              ~~//eettcc//TTeeXX//zzsshh
  2922.  
  2923. These  special escape sequences can also be used with the --PP
  2924. option to pprriinntt:
  2925.  
  2926. %% pprriinntt --PP %%hh ttttyy%%ll
  2927. 1155 ttttyypp11
  2928.  
  2929.  
  2930. The PPOOSSTTEEDDIITT parameter is printed whenever the editor exits.
  2931. This  can  be  useful  for termcap tricks.  To highlight the
  2932. prompt and command line while leaving command output unhigh-
  2933. lighted, try this:
  2934.  
  2935. %% PPOOSSTTEEDDIITT==``eecchhoottcc ssee``
  2936. %% PPRROOMMPPTT==''%%SS%%%% ''
  2937.  
  2938.  
  2939. LLooggiinn//llooggoouutt wwaattcchhiinngg
  2940.  
  2941. You can specify login or logout events to monitor by setting
  2942. the wwaattcchh variable.  Normally, this is done by specifying  a
  2943. list of usernames.
  2944.  
  2945. %% wwaattcchh==(( ppffaallssttaadd ssuubbbbaarraaoo ssuukktthhnnkkrr eeggssiirreerr ))
  2946.  
  2947. The  lloogg  command  reports all people logged in that you are
  2948. watching for.
  2949.  
  2950. %% lloogg
  2951. ppffaallssttaadd hhaass llooggggeedd oonn pp00 ffrroomm mmiicckkeeyy..
  2952. ppffaallssttaadd hhaass llooggggeedd oonn pp55 ffrroomm mmiicckkeeyy..
  2953. %% ...
  2954. ssuubbbbaarraaoo hhaass llooggggeedd oonn pp88 ffrroomm pphhooeenniixx..
  2955. %% ...
  2956. ssuubbbbaarraaoo hhaass llooggggeedd ooffff pp88 ffrroomm pphhooeenniixx..
  2957. %% ...
  2958. ssuukktthhnnkkrr hhaass llooggggeedd oonn pp88 ffrroomm ddeeww..
  2959. %% ...
  2960. ssuukktthhnnkkrr hhaass llooggggeedd ooffff pp88 ffrroomm ddeeww..
  2961.  
  2962. If you specify hostnames with an @@ prepended, the shell will
  2963. watch for all users logging in from the specified host.
  2964.  
  2965.  
  2966.  
  2967.  
  2968.  
  2969.  
  2970.  
  2971.  
  2972.  
  2973.  
  2974.                             -46-
  2975.  
  2976.  
  2977. %% wwaattcchh==(( @@mmiicckkeeyy @@pphhooeenniixx ))
  2978. %% lloogg
  2979. ddjjtthhoonnggss hhaass llooggggeedd oonn qq22 ffrroomm pphhooeenniixx..
  2980. ppffaallssttaadd hhaass llooggggeedd oonn pp00 ffrroomm mmiicckkeeyy..
  2981. ppffaallssttaadd hhaass llooggggeedd oonn pp55 ffrroomm mmiicckkeeyy..
  2982.  
  2983. If  you  give  a tty name with a %% prepended, the shell will
  2984. watch for all users logging in on that tty.
  2985.  
  2986. %% wwaattcchh==(( %%ttttyypp00 %%ccoonnssoollee ))
  2987. %% lloogg
  2988. rroooott hhaass llooggggeedd oonn ccoonnssoollee ffrroomm ..
  2989. ppffaallssttaadd hhaass llooggggeedd oonn pp00 ffrroomm mmiicckkeeyy..
  2990.  
  2991. The format of the reports may also be changed.
  2992.  
  2993. %% wwaattcchh==(( ppffaallssttaadd ggeetttteess eeppss ddjjtthhoonnggss jjccoorrrr bbddaavviiss ))
  2994. %% lloogg
  2995. jjccoorrrr hhaass llooggggeedd oonn ttff ffrroomm 112288..111122..117766..33::00..
  2996. jjccoorrrr hhaass llooggggeedd oonn rr00 ffrroomm 112288..111122..117766..33::00..
  2997. ggeetttteess hhaass llooggggeedd oonn pp44 ffrroomm yyoo::00..00..
  2998. ddjjtthhoonnggss hhaass llooggggeedd oonn ppee ffrroomm ggrruummppyy::00..00..
  2999. ddjjtthhoonnggss hhaass llooggggeedd oonn qq22 ffrroomm pphhooeenniixx..
  3000. bbddaavviiss hhaass llooggggeedd oonn qqdd ffrroomm BBRRUUNNOO..
  3001. eeppss hhaass llooggggeedd oonn pp33 ffrroomm ccssxx3300::00..00..
  3002. ppffaallssttaadd hhaass llooggggeedd oonn pp00 ffrroomm mmiicckkeeyy..
  3003. ppffaallssttaadd hhaass llooggggeedd oonn pp55 ffrroomm mmiicckkeeyy..
  3004. %% WWAATTCCHHFFMMTT==''%%nn oonn ttttyy%%ll ffrroomm %%MM''
  3005. %% lloogg
  3006. jjccoorrrr oonn ttttyyttff ffrroomm 112288..111122..117766..33::00..
  3007. jjccoorrrr oonn ttttyyrr00 ffrroomm 112288..111122..117766..33::00..
  3008. ggeetttteess oonn ttttyypp44 ffrroomm yyoo::00..00
  3009. ddjjtthhoonnggss oonn ttttyyppee ffrroomm ggrruummppyy::00..00
  3010. ddjjtthhoonnggss oonn ttttyyqq22 ffrroomm pphhooeenniixx..PPrriinncceettoo
  3011. bbddaavviiss oonn ttttyyqqdd ffrroomm BBRRUUNNOO..ppppppll..ggoovv
  3012. eeppss oonn ttttyypp33 ffrroomm ccssxx3300::00..00
  3013. ppffaallssttaadd oonn ttttyypp00 ffrroomm mmiicckkeeyy..PPrriinncceettoonn
  3014. ppffaallssttaadd oonn ttttyypp55 ffrroomm mmiicckkeeyy..PPrriinncceettoonn
  3015. %% WWAATTCCHHFFMMTT==''%%nn ffmm %%mm''
  3016. %% lloogg
  3017. jjccoorrrr ffmm 112288..111122..117766..33::00
  3018. jjccoorrrr ffmm 112288..111122..117766..33::00
  3019. ggeetttteess ffmm yyoo::00..00
  3020. ddjjtthhoonnggss ffmm ggrruummppyy::00..00
  3021. ddjjtthhoonnggss ffmm pphhooeenniixx
  3022. bbddaavviiss ffmm BBRRUUNNOO
  3023. eeppss ffmm ccssxx3300::00..00
  3024. ppffaallssttaadd ffmm mmiicckkeeyy
  3025. ppffaallssttaadd ffmm mmiicckkeeyy
  3026. %% WWAATTCCHHFFMMTT==''%%nn %%aa aatt %%tt %%ww..''
  3027. %% lloogg
  3028. jjccoorrrr llooggggeedd oonn aatt 33::1155ppmm MMoonn 2200..
  3029. jjccoorrrr llooggggeedd oonn aatt 33::1166ppmm WWeedd 2222..
  3030. ggeetttteess llooggggeedd oonn aatt 66::5544ppmm WWeedd 2222..
  3031.  
  3032.  
  3033.  
  3034.  
  3035.  
  3036.  
  3037.  
  3038.  
  3039.  
  3040.                             -47-
  3041.  
  3042.  
  3043. ddjjtthhoonnggss llooggggeedd oonn aatt 77::1199aamm TThhuu 2233..
  3044. ddjjtthhoonnggss llooggggeedd oonn aatt 77::2200aamm TThhuu 2233..
  3045. bbddaavviiss llooggggeedd oonn aatt 1122::4400ppmm TThhuu 2233..
  3046. eeppss llooggggeedd oonn aatt 44::1199ppmm TThhuu 2233..
  3047. ppffaallssttaadd llooggggeedd oonn aatt 33::3399aamm FFrrii 2244..
  3048. ppffaallssttaadd llooggggeedd oonn aatt 33::4422aamm FFrrii 2244..
  3049.  
  3050. If you have a ..ffrriieennddss file in your home directory, a conve-
  3051. nient  way  to  make zzsshh watch for all your friends is to do
  3052. this:
  3053.  
  3054. %% wwaattcchh==(( $$((<< ~~//..ffrriieennddss)) ))
  3055. %% eecchhoo $$wwaattcchh
  3056. ssuubbbbaarraaoo mmaarruucchhcckk rroooott ssuukktthhnnkkrr ...
  3057.  
  3058. If watch is set to aallll, then all users  logging  in  or  out
  3059. will be reported.
  3060.  
  3061. OOppttiioonnss
  3062.  
  3063. Some  options  have  already  been mentioned; here are a few
  3064. more:
  3065.  
  3066. Using the _A_U_T_O_C_D option, you can simply type the name  of  a
  3067. directory, and it will become the current directory.
  3068.  
  3069. %% ccdd //
  3070. %% sseettoopptt aauuttooccdd
  3071. %% bbiinn
  3072. %% ppwwdd
  3073. //bbiinn
  3074. %% ....//eettcc
  3075. %% ppwwdd
  3076. //eettcc
  3077.  
  3078. With  _C_D_A_B_L_E_V_A_R_S,  if  the  argument  to ccdd is the name of a
  3079. parameter whose value is a valid directory, it  will  become
  3080. the current directory.
  3081.  
  3082. %% sseettoopptt ccddaabblleevvaarrss
  3083. %% ffoooo==//ttmmpp
  3084. %% ccdd ffoooo
  3085. //ttmmpp
  3086.  
  3087. _C_O_R_R_E_C_T  turns  on spelling correction for commands, and the
  3088. _C_O_R_R_E_C_T_A_L_L option turns on spelling correction for all argu-
  3089. ments.
  3090.  
  3091. %% sseettoopptt ccoorrrreecctt
  3092. %% ssll
  3093. zzsshh:: ccoorrrreecctt ``ssll'' ttoo ``llss'' [[nnyyaaee]]?? yy
  3094. %% sseettoopptt ccoorrrreeccttaallll
  3095. %% llss xx..vv1111rr44
  3096. zzsshh:: ccoorrrreecctt ``xx..vv1111rr44'' ttoo ``XX..VV1111RR44'' [[nnyyaaee]]?? nn
  3097.  
  3098.  
  3099.  
  3100.  
  3101.  
  3102.  
  3103.  
  3104.  
  3105.  
  3106.                             -48-
  3107.  
  3108.  
  3109. //uussrr//pprriinnccttoonn//ssrrcc//xx..vv1111rr44 nnoott ffoouunndd
  3110. %% llss //eettcc//ppaasswwdd
  3111. zzsshh:: ccoorrrreecctt ttoo ``//eettcc//ppaasswwdd'' ttoo ``//eettcc//ppaasssswwdd'' [[nnyyaaee]]?? yy
  3112. //eettcc//ppaasssswwdd
  3113.  
  3114. If  you  press yy when the shell asks you if you want to cor-
  3115. rect a word, it will be corrected.  If you press nn, it  will
  3116. be  left alone.  Pressing aa aborts the command, and pressing
  3117. ee brings the line up for editing again, in  case  you  agree
  3118. the word is spelled wrong but you don't like the correction.
  3119.  
  3120. Normally, a quoted expression may contain a newline:
  3121.  
  3122. %% eecchhoo ''
  3123. >> ffoooo
  3124. >> ''
  3125.  
  3126. ffoooo
  3127.  
  3128. %%
  3129.  
  3130. With _C_S_H_J_U_N_K_I_E_Q_U_O_T_E_S set, this is illegal, as it is in  csh.
  3131.  
  3132. %% sseettoopptt ccsshhjjuunnkkiieeqquuootteess
  3133. %% llss ''ffoooo
  3134. zzsshh:: uunnmmaattcchheedd ''
  3135.  
  3136. _G_L_O_B_D_O_T_S  lets  files  beginning with a .. be matched without
  3137. explicitly specifying the dot.
  3138.  
  3139. %% llss --dd **xx**
  3140. MMaaiillbbooxxeess
  3141. %% sseettoopptt gglloobbddoottss
  3142. %% llss --dd **xx**
  3143. ..eexxrrcc         ..ppnneewwsseexxppeerrtt  ..xxsseerrvveerrrrcc
  3144. ..mmuusshheexxppeerrtt   ..xxiinniittrrcc      MMaaiillbbooxxeess
  3145.  
  3146. _H_I_S_T_I_G_N_O_R_E_D_U_P_S prevents the current line from being saved in
  3147. the  history  if it is the same as the previous one; _H_I_S_T_I_G_-
  3148. _N_O_R_E_S_P_A_C_E prevents the current line from being saved  if  it
  3149. begins with a space.
  3150.  
  3151. %% PPRROOMMPPTT==''%%hh>> ''
  3152. 3399>> sseettoopptt hhiissttiiggnnoorreedduuppss
  3153. 4400>> eecchhoo ffoooo
  3154. ffoooo
  3155. 4411>> eecchhoo ffoooo
  3156. ffoooo
  3157. 4411>> eecchhoo ffoooo
  3158. ffoooo
  3159. 4411>> eecchhoo bbaarr
  3160. bbaarr
  3161. 4422>> sseettoopptt hhiissttiiggnnoorreessppaaccee
  3162. 4433>>  eecchhoo ffoooo
  3163.  
  3164.  
  3165.  
  3166.  
  3167.  
  3168.  
  3169.  
  3170.  
  3171.  
  3172.                             -49-
  3173.  
  3174.  
  3175. ffoooo
  3176. 4433>>  eecchhoo ffuubbaarr
  3177. ffuubbaarr
  3178. 4433>>  eecchhoo ffuubbaarr
  3179. ffuubbaarr
  3180.  
  3181. _I_G_N_O_R_E_B_R_A_C_E_S turns off csh-style brace expansion.
  3182.  
  3183. %% eecchhoo xx{{yy{{zz,,aa}},,{{bb,,cc}}dd}}ee
  3184. xxyyzzee xxyyaaee xxbbddee xxccddee
  3185. %% sseettoopptt iiggnnoorreebbrraacceess
  3186. %% eecchhoo xx{{yy{{zz,,aa}},,{{bb,,cc}}dd}}ee
  3187. xx{{yy{{zz,,aa}},,{{bb,,cc}}dd}}ee
  3188.  
  3189. _I_G_N_O_R_E_E_O_F forces the user to type eexxiitt or llooggoouutt, instead of
  3190. just pressing _^_D.
  3191.  
  3192. %% sseettoopptt iiggnnoorreeeeooff
  3193. %% ^^DD
  3194. zzsshh:: uussee ''eexxiitt'' ttoo eexxiitt..
  3195.  
  3196. _I_N_T_E_R_A_C_T_I_V_E_C_O_M_M_E_N_T_S turns on interactive comments;  comments
  3197. begin with a ##.
  3198.  
  3199. %% sseettoopptt iinntteerraaccttiivveeccoommmmeennttss
  3200. %% ddaattee ## tthhiiss iiss aa ccoommmmeenntt
  3201. FFrrii MMaayy 2244 0066::5544::1144 EEDDTT 11999911
  3202.  
  3203. _N_O_B_E_E_P makes sure the shell never beeps.
  3204.  
  3205. _N_O_C_L_O_B_B_E_R  prevents  you  from  accidentally  overwriting an
  3206. existing file.
  3207.  
  3208. %% sseettoopptt nnoocclloobbbbeerr
  3209. %% ccaatt //ddeevv//nnuullll >>~~//..zzsshhrrcc
  3210. zzsshh:: ffiillee eexxiissttss:: //uu//ppffaallssttaadd//..zzsshhrrcc
  3211.  
  3212. If you really do want to clobber a file, you can use the  >>!!
  3213. operator.   To  make  things  easier  in this case, the >> is
  3214. stored in the history list as a >>!!:
  3215.  
  3216. %% ccaatt //ddeevv//nnuullll >>!! ~~//..zzsshhrrcc
  3217. %% ccaatt //eettcc//mmoottdd >> ~~//..zzsshhrrcc
  3218. zzsshh:: ffiillee eexxiissttss:: //uu//ppffaallssttaadd//..zzsshhrrcc
  3219. %% !!!!
  3220. ccaatt //eettcc//mmoottdd >>!! ~~//..zzsshhrrcc
  3221. %% ...
  3222.  
  3223. _R_C_Q_U_O_T_E_S lets you use a more elegant  method  for  including
  3224. single quotes in a singly quoted string:
  3225.  
  3226. %% eecchhoo ''""ddoonn''\\''''tt ddoo tthhaatt..""''
  3227. ""ddoonn''tt ddoo tthhaatt..""
  3228. %% eecchhoo ''""ddoonn''''tt ddoo tthhaatt..""''
  3229.  
  3230.  
  3231.  
  3232.  
  3233.  
  3234.  
  3235.  
  3236.  
  3237.  
  3238.                             -50-
  3239.  
  3240.  
  3241. ""ddoonntt ddoo tthhaatt..""
  3242. %% sseettoopptt rrccqquuootteess
  3243. %% eecchhoo ''""ddoonn''''tt ddoo tthhaatt..""''
  3244. ""ddoonn''tt ddoo tthhaatt..""
  3245.  
  3246. Finally,  _S_U_N_K_E_Y_B_O_A_R_D_H_A_C_K  wins  the award for the strangest
  3247. option.  If a line ends with ``, and there are an odd  number
  3248. of  them  on the line, the shell will ignore the trailing ``.
  3249. This is provided for  keyboards  whose  RETURN  key  is  too
  3250. small, and too close to the `` key.
  3251.  
  3252. %% sseettoopptt ssuunnkkeeyybbooaarrddhhaacckk
  3253. %% ddaattee``
  3254. FFrrii MMaayy 2244 0066::5555::3388 EEDDTT 11999911
  3255.  
  3256.  
  3257. CClloossiinngg CCoommmmeennttss
  3258.  
  3259. I  (Bas  de Bakker) would be happy to receive mail if anyone
  3260. has any tricks or ideas to add to this document, or if there
  3261. are  some  points that could be made clearer or covered more
  3262. thoroughly.  Please notify me of any errors  in  this  docu-
  3263. ment.
  3264.  
  3265.  
  3266.  
  3267.  
  3268.  
  3269.  
  3270.  
  3271.  
  3272.  
  3273.  
  3274.  
  3275.  
  3276.  
  3277.  
  3278.  
  3279.  
  3280.  
  3281.  
  3282.  
  3283.  
  3284.  
  3285.  
  3286.  
  3287.  
  3288.  
  3289.  
  3290.  
  3291.  
  3292.  
  3293.  
  3294.  
  3295.  
  3296.  
  3297.  
  3298.  
  3299.  
  3300.  
  3301.  
  3302.  
  3303.  
  3304.                             -51-
  3305.  
  3306.  
  3307.                      TTaabbllee ooff CCoonntteennttss
  3308.  
  3309.  
  3310.  
  3311. Introduction . . . . . . . . . . . . . . . . . . . . . .   1
  3312.  
  3313. Filename Generation  . . . . . . . . . . . . . . . . . .   1
  3314.  
  3315. Startup Files  . . . . . . . . . . . . . . . . . . . . .   5
  3316.  
  3317. Shell Functions  . . . . . . . . . . . . . . . . . . . .   6
  3318.  
  3319. Directories  . . . . . . . . . . . . . . . . . . . . . .   9
  3320.  
  3321. Directory Stacks . . . . . . . . . . . . . . . . . . . .  11
  3322.  
  3323. Command/Process Substitution . . . . . . . . . . . . . .  14
  3324.  
  3325. Redirection  . . . . . . . . . . . . . . . . . . . . . .  17
  3326.  
  3327. Aliasing . . . . . . . . . . . . . . . . . . . . . . . .  17
  3328.  
  3329. History  . . . . . . . . . . . . . . . . . . . . . . . .  21
  3330.  
  3331. Command Line Editing . . . . . . . . . . . . . . . . . .  23
  3332.  
  3333. Completion . . . . . . . . . . . . . . . . . . . . . . .  27
  3334.  
  3335. Extended completion  . . . . . . . . . . . . . . . . . .  32
  3336.  
  3337. Bindings . . . . . . . . . . . . . . . . . . . . . . . .  35
  3338.  
  3339. Parameter Substitution . . . . . . . . . . . . . . . . .  36
  3340.  
  3341. Shell Parameters . . . . . . . . . . . . . . . . . . . .  40
  3342.  
  3343. Prompting  . . . . . . . . . . . . . . . . . . . . . . .  44
  3344.  
  3345. Login/logout watching  . . . . . . . . . . . . . . . . .  45
  3346.  
  3347. Options  . . . . . . . . . . . . . . . . . . . . . . . .  47
  3348.  
  3349. Closing Comments . . . . . . . . . . . . . . . . . . . .  50
  3350.  
  3351.  
  3352.  
  3353.  
  3354.  
  3355.  
  3356.  
  3357.  
  3358.  
  3359.  
  3360.  
  3361.  
  3362.  
  3363.  
  3364.  
  3365.  
  3366.  
  3367.