From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id D0AB61381F3 for ; Sun, 4 Aug 2013 12:52:50 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 59AB3E0A6A; Sun, 4 Aug 2013 12:52:50 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id F08CDE0A6A for ; Sun, 4 Aug 2013 12:52:49 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id C67EC33EDCB for ; Sun, 4 Aug 2013 12:52:48 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 19617E468F for ; Sun, 4 Aug 2013 12:52:46 +0000 (UTC) From: "Michał Górny" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Michał Górny" Message-ID: <1375620751.60be72ab342125187f42cf574a43fe8def36b423.mgorny@gentoo> Subject: [gentoo-commits] proj/gentoopm:master commit in: gentoopm/bash/ X-VCS-Repository: proj/gentoopm X-VCS-Files: gentoopm/bash/bashserver.py X-VCS-Directories: gentoopm/bash/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: 60be72ab342125187f42cf574a43fe8def36b423 X-VCS-Branch: master Date: Sun, 4 Aug 2013 12:52:46 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 5b246274-77d0-4c7b-8a48-b31840d48ddd X-Archives-Hash: 67ed8dfcf9f553d853bada63ddbc9473 commit: 60be72ab342125187f42cf574a43fe8def36b423 Author: Michał Górny gentoo org> AuthorDate: Sun Aug 4 12:49:10 2013 +0000 Commit: Michał Górny gentoo org> CommitDate: Sun Aug 4 12:52:31 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=60be72ab Use 'bash -n' to check syntax rather than 'source' output. This fixes throwing InvalidBashCodeError whenever script ends with a command having non-zero exit status. --- gentoopm/bash/bashserver.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gentoopm/bash/bashserver.py b/gentoopm/bash/bashserver.py index 850f2ab..0db1dff 100644 --- a/gentoopm/bash/bashserver.py +++ b/gentoopm/bash/bashserver.py @@ -42,8 +42,14 @@ class BashServer(BashParser): f.flush() self._write('exit 0', - 'source %s && printf "OK\\0" || printf "FAIL\\0"' % repr(f.name)) + 'bash -n %s && printf "OK\\0" || printf "FAIL\\0"' % repr(f.name)) resp = self._read1() + + if resp == 'OK': + self._write('source %s >&2; printf "DONE\\0"' % repr(f.name)) + if self._read1() != 'DONE': + raise AssertionError('Sourcing unexpected caused stdout output') + f.close() if resp != 'OK':