From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1QhkwT-0000aQ-HB for garchives@archives.gentoo.org; Fri, 15 Jul 2011 16:08:41 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 04E7B21C31F; Fri, 15 Jul 2011 16:08:23 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id C78F721C317 for ; Fri, 15 Jul 2011 16:08:23 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 5B67C2AC31C for ; Fri, 15 Jul 2011 16:08:23 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 1839C80042 for ; Fri, 15 Jul 2011 16:08:22 +0000 (UTC) From: "Michał Górny" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Michał Górny" Message-ID: <49592d5dd7f16f63c4160a919d64e27f4ebe1943.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: 49592d5dd7f16f63c4160a919d64e27f4ebe1943 Date: Fri, 15 Jul 2011 16:08:22 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: d71bf8158fcbf616c4aa9eb7c7311bd0 commit: 49592d5dd7f16f63c4160a919d64e27f4ebe1943 Author: Micha=C5=82 G=C3=B3rny gentoo org> AuthorDate: Fri Jul 15 15:27:08 2011 +0000 Commit: Micha=C5=82 G=C3=B3rny gentoo org> CommitDate: Fri Jul 15 15:28:32 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/gentoopm.git;= a=3Dcommit;h=3D49592d5d BashServer: don't hardcode any specific bash commands. --- gentoopm/bash/bashserver.py | 16 +++++----------- 1 files changed, 5 insertions(+), 11 deletions(-) diff --git a/gentoopm/bash/bashserver.py b/gentoopm/bash/bashserver.py index 1690627..f65535e 100644 --- a/gentoopm/bash/bashserver.py +++ b/gentoopm/bash/bashserver.py @@ -10,15 +10,8 @@ from gentoopm.bash import BashParser _bash_script =3D ''' while true; do ( - source %s while read -r __GENTOOPM_CMD; do eval ${__GENTOOPM_CMD} - if [[ ${#} -eq 0 ]]; then - # reload env file - break - else - printf "%%s\\0" "${@}" - fi done ) done @@ -31,8 +24,7 @@ class BashServer(BashParser): =20 def __init__(self): self._tmpf =3D tempfile.NamedTemporaryFile('w+b') - self._bashproc =3D subprocess.Popen(['bash', '-c', - _bash_script % repr(self._tmpf.name)], + self._bashproc =3D subprocess.Popen(['bash', '-c', _bash_script], stdin =3D subprocess.PIPE, stdout =3D subprocess.PIPE, env =3D {}) =20 @@ -48,7 +40,8 @@ class BashServer(BashParser): shutil.copyfileobj(envf, f) f.flush() =20 - self._write('set --') + self._write('break', + 'source %s' % repr(f.name)) =20 def _read1(self): f =3D self._bashproc.stdout @@ -64,7 +57,8 @@ class BashServer(BashParser): =20 def _cmd_print(self, *varlist): q =3D ' '.join(['"${%s}"' % v for v in varlist]) - self._write('set -- %s' % q) + self._write('set -- %s' % q, + 'printf "%s\\0" "${@}"') return [self._read1() for v in varlist] =20 def __getitem__(self, k):