ALT Linux Team development discussions
 help / color / mirror / Atom feed
From: Alexey Rusakov <ktirf@altlinux.ru>
To: ALT Devel discussion list <devel@altlinux.ru>
Subject: Re: [devel] Код возврата при конвейере
Date: Sun, 06 Mar 2005 20:39:13 +0300
Message-ID: <422B4041.5000106@altlinux.ru> (raw)
In-Reply-To: <20050306171404.GA9530@basalt.office.altlinux.org>

Dmitry V. Levin wrote:

>Hi,
>
>On Sun, Mar 06, 2005 at 02:15:40PM +0300, Vitaly Lipatov wrote:
>  
>
>>Не могу понять, как узнать код возврата
>>программы при такой конструкции:
>>
>>программа | tea 
>>
>>Подскажите пожалуйста.
>>    
>>
>
>Кодом возврата pipeline'а является код возврата последней команды,
>поэтому узнать код возврата других команд можно, например, так:
>
>rm -f failed
>(программа || touch failed) | tea
>if [ -f failed ]; then
>	обработка ошибки
>fi
>  
>
При условии, что не требуется вывод tea писать в переменную, можно написать
RETVAL=`{ (программа ; echo $? >&5) | tea } 5>&1`
if [ $RETVAL ... ]; then
  ...
fi

Более громоздко, зато не требует наличия файловой системы вообще :)

-- 
  Alexey "Ktirf" Rusakov


  reply	other threads:[~2005-03-06 17:39 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-06 11:15 Vitaly Lipatov
2005-03-06 17:14 ` Dmitry V. Levin
2005-03-06 17:39   ` Alexey Rusakov [this message]
2005-03-06 17:53   ` Alexey I. Froloff
2005-03-07 12:13     ` Alexey Rusakov
2005-03-08 16:18       ` Alexey I. Froloff
2005-03-08 17:34         ` Alexey Rusakov
2005-03-08 20:03           ` Alexey I. Froloff
2005-03-08 20:09             ` Alexey I. Froloff
2005-03-08 20:35               ` [devel] [JT] " Alexey Rusakov
2005-03-08 21:51             ` [devel] " Dmitry V. Levin
2005-03-09  9:13               ` [devel] " Michael Shigorin
2005-03-10  6:18     ` Alexey Tourbin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=422B4041.5000106@altlinux.ru \
    --to=ktirf@altlinux.ru \
    --cc=devel@altlinux.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

ALT Linux Team development discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \
		devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru
	public-inbox-index devel

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git