X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=t%2Fid-other-than;h=eb6aead51281c1f52302fe1931d3a3f8a3514877;hb=bf67f94dd4f4096de4eee07a7dc377d6c889a016;hp=7aef3ae0b8e14d694c59d1dd8c337f2c07d05259;hpb=275562a8101b08cfc205b0e4a9d6e4e55de44b5b;p=bup.git diff --git a/t/id-other-than b/t/id-other-than index 7aef3ae..eb6aead 100755 --- a/t/id-other-than +++ b/t/id-other-than @@ -1,4 +1,11 @@ -#!/usr/bin/env python +#!/bin/sh +"""": # -*-python-*- +bup_python="$(dirname "$0")/../cmd/bup-python" || exit $? +exec "$bup_python" "$0" ${1+"$@"} +""" +# end of bup preamble + +from __future__ import absolute_import import grp import pwd @@ -18,17 +25,21 @@ def is_integer(x): except ValueError, e: return False -excluded_ids = frozenset(int(x) for x in sys.argv[2:] if is_integer(x)) -excluded_names = frozenset(x for x in sys.argv[2:] if not is_integer(x)) +excluded_ids = set(int(x) for x in sys.argv[2:] if is_integer(x)) +excluded_names = (x for x in sys.argv[2:] if not is_integer(x)) if sys.argv[1] == '--user': + for x in excluded_names: + excluded_ids.add(pwd.getpwnam(x).pw_uid) for x in pwd.getpwall(): - if x.pw_name not in excluded_names and x.pw_uid not in excluded_ids: + if x.pw_uid not in excluded_ids: print x.pw_name + ':' + str(x.pw_uid) sys.exit(0) elif sys.argv[1] == '--group': + for x in excluded_names: + excluded_ids.add(grp.getgrnam(x).gr_gid) for x in grp.getgrall(): - if x.gr_name not in excluded_names and x.gr_gid not in excluded_ids: + if x.gr_gid not in excluded_ids: print x.gr_name + ':' + str(x.gr_gid) sys.exit(0) else: