|
|
ru.unix- RU.UNIX ---------------------------------------------------------------------- From : Serge Matveev 2:5020/52 27 Apr 2005 20:52:57 To : Kirill Timofeev Subject : Re: error handler in shell script --------------------------------------------------------------------------------
KT> В пеpле можно опpеделить функцию AUTOLOAD и тогда пpи вызове
KT> неопpеделенной функции будет вызываться этот самый AUTOLOAD с
KT> паpаметpами пеpвоначальной функции. Можно ли сделать так же на шелле? В
KT> zsh есть тpап, котоpый обpабатывает ошибки (ZERR), но можно ли сделать
KT> с его помощью пеpедачу паpаметpов я пока не понял.
$ man sh
trap [action signal ...]
Cause the shell to parse and execute action when any of the speci-
fied signals are received. The signals are specified by signal
number or as the name of the signal. If signal is 0, the action
is executed when the shell exits. action may be null, which cause
the specified signals to be ignored. With action omitted or set
to `-' the specified signals are set to their default action.
When the shell forks off a subshell, it resets trapped (but not
ignored) signals to the default action. The trap command has no
effect on signals that were ignored on entry to the shell. trap
without any arguments cause it to write a list of signals and
their associated action to the standard output in a format that is
suitable as an input to the shell that achieves the same trapping
results.
Examples:
trap
List trapped signals and their corresponding action
trap '' INT QUIT tstp 30
Ignore signals INT QUIT TSTP USR1
trap date INT
Print date upon receiving signal INT
sh у меня - dash (The Debian Almquist Shell - a POSIX compliant shell).
Так что должно работать.
serge@matveev spb ru Serge Matveev & ...
ICQ 3575357
--- tin/1.7.8-20050315 ("Scalpay") (UNIX) (Linux/2.6.8-2-686 (i686))
* Origin: После нас пришло новое поколение и выбрало Pepsi. (2:5020/52.0)
Вернуться к списку тем, сортированных по: возрастание даты уменьшение даты тема автор
Архивное /ru.unix/4270587d55ead.html, оценка из 5, голосов 10
|