#
# Bash source file for retrieving fullname form /etc/passwd
# 
# (C) 2011-2012 Felix Hauri - felix@f-hauri.ch
# Licensed under terms of LGPL v3. www.gnu.org
    
# after sourcing script:
# syntaxe: username <user>

username() {
    sed </etc/passwd -ne '
      /^'${1:-$USER}':/{
	s/^\([^:]*:\)\{4\}\([^,:]\+\)[,:].*$/\2/p;
	tb;
	bc;
       :b
	q;
       :c
	s/^\([^:]*\):.*$/\1/p;
	q
      } '
}
export -f username
