~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Martin Pool
  • Date: 2005-03-12 07:16:39 UTC
  • Revision ID: mbp@sourcefrog.net-20050312071639-0a8f59a34a024ff0
cope when gecos field doesn't have a comma

reported by ysaito, rooneg -- thanks

Show diffs side-by-side

added added

removed removed

Lines of Context:
135
135
        import pwd
136
136
        uid = os.getuid()
137
137
        w = pwd.getpwuid(uid)
138
 
        realname, junk = w.pw_gecos.split(',', 1)
 
138
        gecos = w.pw_gecos
 
139
        comma = gecos.find(',')
 
140
        if comma == -1:
 
141
            realname = gecos
 
142
        else:
 
143
            realname = gecos[:comma]
139
144
        return '%s <%s@%s>' % (realname, w.pw_name, socket.getfqdn())
140
145
    except ImportError:
141
146
        pass