~ubuntu-branches/ubuntu/karmic/zsh/karmic

« back to all changes in this revision

Viewing changes to Doc/Zsh/builtins.yo

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2009-06-02 10:40:25 UTC
  • mfrom: (1.2.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20090602104025-lg6wynxpzqi08k2i
Tags: 4.3.10-1ubuntu1
* Resynchronise with Debian. Remaining changes:
  + debian/zshrc: Enable completions by default, unless
    skip_global_compinit is set

Show diffs side-by-side

added added

removed removed

Lines of Context:
131
131
With the tt(-w) flag, the var(name)s are taken as names of files compiled
132
132
with the tt(zcompile) builtin, and all functions defined in them are
133
133
marked for autoloading.
 
134
 
 
135
The flags tt(-z) and tt(-k) mark the function to be autoloaded in
 
136
native or ksh emulation, as if the option tt(KSH_AUTOLOAD) were
 
137
unset or were set, respectively.  The flags override the setting of
 
138
the option at the time the function is loaded.
134
139
)
135
140
findex(bg)
136
141
cindex(jobs, backgrounding)
338
343
cindex(sh, compatibility)
339
344
cindex(ksh, compatibility)
340
345
cindex(csh, compatibility)
341
 
item(tt(emulate) [ tt(-LR) ] {tt(zsh)|tt(sh)|tt(ksh)|tt(csh)})(
342
 
Set up zsh options to emulate the specified shell as much as possible.
 
346
item(tt(emulate) [ tt(-LR) ] [ {tt(zsh)|tt(sh)|tt(ksh)|tt(csh)} [ tt(-c) tt(arg) ] ])(
 
347
Without any argument print current emulation mode.
 
348
 
 
349
With single argument set up zsh options to emulate the specified shell
 
350
as much as possible.
343
351
bf(csh) will never be fully emulated.
344
352
If the argument is not one of the shells listed above, tt(zsh)
345
353
will be used as a default; more precisely, the tests performed on the
351
359
ifnzman(\
352
360
noderef(Compatibility)
353
361
)\
354
 
.  If the tt(-R) option is given, all options
 
362
.
 
363
 
 
364
If the tt(-R) option is given, all options
355
365
are reset to their default value corresponding to the specified emulation
356
366
mode, except for certain options describing the interactive
357
367
environment; otherwise, only those options likely to cause portability
358
 
problems in scripts and functions are altered.  If the tt(-L) option
359
 
is given, the options tt(LOCAL_OPTIONS) and tt(LOCAL_TRAPS) will be set as
 
368
problems in scripts and functions are altered.  If the tt(-L) option is given,
 
369
the options tt(LOCAL_OPTIONS) and tt(LOCAL_TRAPS) will be set as
360
370
well, causing the effects of the tt(emulate) command and any tt(setopt) and
361
371
tt(trap) commands to be local to the immediately surrounding shell
362
372
function, if any; normally these options are turned off in all emulation
363
 
modes except tt(ksh).
 
373
modes except tt(ksh). The tt(-L) and tt(-c) are mutually exclusive.
 
374
 
 
375
If tt(-c) tt(arg) is given, evaluate tt(arg) while the requested
 
376
emulation is temporarily in effect.  The emulation and all options will
 
377
be restored to their original values before tt(emulate) returns.  The
 
378
tt(-R) flag may be used.
 
379
 
 
380
Use of tt(-c) enables `sticky' emulation mode for functions defined
 
381
within the evaluated expression:  the emulation mode is associated
 
382
thereafter with the function so that whenever the function is executed
 
383
the emulation (respecting the tt(-R) flag, if present) and all
 
384
options are set before entry to the function, and restored after exit.
 
385
If the function is called when the sticky emulation is already in
 
386
effect, either within an `tt(emulate) var(shell) tt(-c)' expression or
 
387
within another function with the same sticky emulation, entry and exit
 
388
from the function do not cause options to be altered (except due to
 
389
standard processing such as the tt(LOCAL_OPTIONS) option).
 
390
 
 
391
For example:
 
392
 
 
393
example(emulate sh -c 'fni+LPAR()RPAR() { setopt cshnullglob; }
 
394
fno+LPAR()RPAR() { fni; }'
 
395
fno
 
396
)
 
397
 
 
398
The two functions tt(fni) and tt(fno) are defined with sticky tt(sh)
 
399
emulation.  tt(fno) is then executed, causing options associated
 
400
with emulations to be set to their values in tt(sh).  tt(fni) then
 
401
calls tt(fno); because tt(fno) is also marked for sticky tt(sh)
 
402
emulation, no option changes take place on entry to or exit from it.
 
403
Hence the option tt(cshnullglob), turned off by tt(sh) emulation, will
 
404
be turned on within tt(fni) and remain on on return to tt(fno).  On exit
 
405
from tt(fno), the emulation mode and all options will be restored to the
 
406
state they were in before entry to the temporary emulation.
 
407
 
 
408
The documentation above is typically sufficient for the intended
 
409
purpose of executing code designed for other shells in a suitable
 
410
environment.  More detailed rules follow.
 
411
startsitem()
 
412
sitem(1.)(The sticky emulation environment provided by `tt(emulate)
 
413
var(shell) tt(-c)' is identical to that provided by entry to
 
414
a function marked for sticky emulation as a consequence of being
 
415
defined in such an environment.  Hence, for example, the sticky
 
416
emulation is inherited by subfunctions defined within functions
 
417
with sticky emulation.)
 
418
sitem(2.)(No change of options takes place on entry to or exit from
 
419
functions that are not marked for sticky emulation, other than those
 
420
that would normally take place, even if those functions are called
 
421
within sticky emulation.)
 
422
sitem(3.)(No special handling is provided for functions marked for
 
423
tt(autoload) nor for functions present in wordcode created by
 
424
the tt(zcompile) command.)
 
425
sitem(4.)(The presence or absence of the tt(-R) flag to tt(emulate)
 
426
corresponds to different sticky emulation modes, so for example
 
427
`tt(emulate sh -c)', `tt(emulate -R sh -c)' and `tt(emulate csh -c)'
 
428
are treated as three distinct sticky emulations.)
 
429
endsitem()
364
430
)
365
431
findex(enable)
366
432
cindex(enabling commands)
418
484
findex(fc)
419
485
cindex(history, editing)
420
486
cindex(editing history)
421
 
xitem(tt(fc) [ tt(-e) var(ename) ] [ tt(-nlrdDfEim) ] [ var(old)tt(=)var(new) ... ] [ var(first) [ var(last) ] ])
 
487
xitem(tt(fc) [ tt(-e) var(ename) ] [ tt(-m) var(match) ] [ var(old)tt(=)var(new) ... ] [ var(first) [ var(last) ] ])
 
488
xitem(tt(fc) tt(-l) [ tt(-nrdfEiD) ] [ tt(-t) var(timefmt) ] [ tt(-m) var(match) ])
 
489
xitem(      [ var(old)tt(=)var(new) ... ] [ var(first) [ var(last) ] ])
422
490
xitem(tt(fc) tt(-p) [ tt(-a) ] [ var(filename) [ var(histsize) [ var(savehistsize) ] ] ])
423
491
xitem(tt(fc) tt(-P))
424
492
item(tt(fc) tt(-ARWI) [ var(filename) ])(
451
519
 
452
520
The flag tt(-r) reverses the order of the commands and the
453
521
flag tt(-n) suppresses command numbers when listing.
454
 
Also when listing, tt(-d) prints timestamps for each command, and
455
 
tt(-f) prints full time-date stamps.  Adding the tt(-E) flag
456
 
causes the dates to be printed as `var(dd)tt(.)var(mm)tt(.)var(yyyy)',
457
 
instead of the default `var(mm)tt(/)var(dd)tt(/)var(yyyy)'.
458
 
Adding the tt(-i) flag causes the dates to be printed in ISO8601
459
 
`var(yyyy)tt(-)var(mm)tt(-)var(dd)' format.
460
 
With the tt(-D) flag, tt(fc) prints elapsed times.
 
522
 
 
523
Also when listing,
 
524
startsitem()
 
525
sitem(tt(-d))(prints timestamps for each command)
 
526
sitem(tt(-f))(prints full time-date stamps in the US
 
527
`var(MM)tt(/)var(DD)tt(/)var(YY) var(hh):var(mm)' format)
 
528
sitem(tt(-E))(prints full time-date stamps in the European
 
529
`var(dd)tt(.)var(mm)tt(.)var(yyyy) var(hh):var(mm)' format)
 
530
sitem(tt(-i))(prints full time-date stamps in ISO8601
 
531
`var(yyyy)tt(-)var(mm)tt(-)var(dd) var(hh):var(mm)' format)
 
532
sitem(tt(-t) var(fmt))(prints time and date stamps in the given format;
 
533
var(fmt) is formatted with the strftime function with the zsh extensions
 
534
described for the tt(%D{)var(string)tt(}) prompt format in
 
535
ifzman(the section EXPANSION OF PROMPT SEQUENCES in zmanref(zshmisc))\
 
536
ifnzman(noderef(Prompt Expansion)).  The resulting formatted string must be
 
537
no more than 256 characters or will not be printed.
 
538
)
 
539
sitem(tt(-D))(prints elapsed times; may be combined with one of the
 
540
options above.)
 
541
endsitem()
461
542
 
462
543
cindex(history, stack)
463
544
cindex(stack, history)
889
970
)
890
971
item(tt(-P))(
891
972
Perform prompt expansion (see
892
 
ifzman(zmanref(zshmisc))\
 
973
ifzman(EXPANSION OF PROMPT SEQUENCES in zmanref(zshmisc))\
893
974
ifnzman(noderef(Prompt Expansion))\
894
975
).
895
976
)
1130
1211
findex(return)
1131
1212
cindex(functions, returning from)
1132
1213
item(tt(return) [ var(n) ])(
1133
 
Causes a shell function or tt(.) script to return to
 
1214
Causes a shell function or `tt(.)' script to return to
1134
1215
the invoking script with the return status specified by var(n).  If var(n)
1135
1216
is omitted, the return status is that of the last command
1136
1217
executed.
1237
1318
)
1238
1319
findex(source)
1239
1320
item(tt(source) var(file) [ var(arg) ... ])(
1240
 
Same as tt(.), except that the current directory is always searched and
 
1321
Same as `tt(.)', except that the current directory is always searched and
1241
1322
is always searched first, before directories in tt($path).
1242
1323
)
1243
1324
module(stat)(zsh/stat)