summaryrefslogtreecommitdiff
path: root/localuserinfo
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2010-09-16 13:58:43 +0200
committerJonas Smedegaard <dr@jones.dk>2010-09-16 13:58:43 +0200
commit5969ae05e8ea7c71a3f95684572618c69ce76216 (patch)
treea106d22477dcf807a1f087acdf9020b580d937d7 /localuserinfo
parent8181988dd6e2e1ca34f66bbf16d13db5a3cbc934 (diff)
Support %-appended officehints, and display that (not office) by default.
Diffstat (limited to 'localuserinfo')
-rwxr-xr-xlocaluserinfo18
1 files changed, 14 insertions, 4 deletions
diff --git a/localuserinfo b/localuserinfo
index 3a4e63a..f4d5871 100755
--- a/localuserinfo
+++ b/localuserinfo
@@ -33,7 +33,8 @@ our $verbose = 1; # should we be verbose?
my $ignore_badname = 0; # should we ignore bad names?
my $include_username = 1;
my $include_fullname = 1;
-my $include_office = 1;
+my $include_office = 0;
+my $include_officehints = 1;
my $include_workphone = 1;
my $include_homephone = 1;
my $include_other = 0;
@@ -58,6 +59,7 @@ unless (
"username" => \$include_username,
"fullname|n" => \$include_fullname,
"office" => \$include_office,
+ "officehints" => \$include_officehints,
"workphone" => \$include_workphone,
"homephone" => \$include_homephone,
"other" => \$include_other,
@@ -83,6 +85,7 @@ my @infochunks;
push (@infochunks, 'username') if ($include_username);
push (@infochunks, 'fullname') if ($include_fullname);
push (@infochunks, 'office') if ($include_office);
+push (@infochunks, 'officehints') if ($include_officehints);
push (@infochunks, 'workphone') if ($include_workphone);
push (@infochunks, 'homephone') if ($include_homephone);
push (@infochunks, 'other') if ($include_other);
@@ -95,7 +98,7 @@ while (my $username = shift @names) {
my $string;
- my ($fullname, $office, $workphone, $homephone, $other, @addresshints) = &getuserinfo($username);
+ my ($fullname, $office, $workphone, $homephone, $other, @officehints, @addresshints) = &getuserinfo($username);
my $mailaddress = "$username\@$maildomain";
$string = $template;
@@ -105,8 +108,11 @@ while (my $username = shift @names) {
$string =~ s/\%workphone\%/$workphone/g;
$string =~ s/\%homephone\%/$homephone/g;
$string =~ s/\%other\%/$other/g;
+ $string =~ s/\%officehints\%/@officehints/g;
$string =~ s/\%addresshints\%/@addresshints/g;
$string =~ s/\%mailaddress\%/$mailaddress/g;
+# $string =~ s/\%groups\%/$groups/g;
+# $string =~ s/\%grouphints\%/$grouphints/g;
print "$string\n";
}
@@ -117,6 +123,7 @@ sub getuserinfo($) {
my $pw = getpwnam($username) || die "Username \"$username\" does not exist.";
my ($fullname, $office, $workphone, $homephone, $other) = split /\s*,\s*/, $pw->gecos;
+ my @officehints = grep {s/^([\.[:alnum:]_-]+)$/%$1/} split /\s+/, $office;
my @addresshints;
if (defined($other)) {
@addresshints = grep {/^([\.[:alnum:]_-]+|\+)?@([\.[:alnum:]_-]+)?$/} split /\s+/, $other;
@@ -124,7 +131,7 @@ sub getuserinfo($) {
$other = "";
}
- return ($fullname, $office, $workphone, $homephone, $other, @addresshints);
+ return ($fullname, $office, $workphone, $homephone, $other, @officehints, @addresshints);
}
sub get_maildomain {
@@ -172,6 +179,8 @@ general options:
--username include username
--fullname | -n include fullname
--office include office
+ --officehints include office hints: words in "office" field
+ with "%" appended
--workphone include work phone
--homephone include home phone
--other include full "other" field
@@ -182,7 +191,8 @@ general options:
available infochunks:
* username
* fullname
- * office
+ office
+ * officehints
* workphone
* homephone
other