[Adduser-devel] argh
Stephen Gran
sgran at debian.org
Wed Apr 26 14:57:30 UTC 2006
This one time, at band camp, Stephen Gran said:
> This one time, at band camp, Marc Haber said:
> > On Wed, Apr 26, 2006 at 02:44:07PM +0100, Stephen Gran wrote:
> > > Changing it to
> > > &usage, exit 1 unless ( GetOptions...
> >
> > Besides from this construct rating rather high on the obfuscated perl
> > scale, its output seems acceptable to me.
>
> OK, fair enough :)
and so here is a patch that does so.
It also fixes up 2 sorts of errors:
The first:
dief ("$0: "
which results in output like:
adduser: adduser:
The second is and constructs like:
"foo ", gtx( ...
which produces no output at all. gtx is a subroutine that just returns
gettext'ized text from the input, so it doesn't itself output anything.
Take care,
Index: adduser
===================================================================
--- adduser (revision 556)
+++ adduser (working copy)
@@ -105,6 +105,7 @@
our @names;
# Parse options, sanity checks
+unless (
GetOptions ("quiet" => sub { $verbose = 0 },
"force-badname" => \$allow_badname,
"help|h" => sub { &usage(); exit 0 },
@@ -123,10 +124,14 @@
"gid=i" => \$new_gid,
"conf=s" => \$configfile,
"no-create-home" => \$no_create_home,
- "debug" => sub { $verbose = 2 } );
+ "debug" => sub { $verbose = 2 } )
+) {
+ &usage;
+ exit 1;
+}
# everyone can issue "--help" and "--version", but only root can go on
-dief ("$0: ",gtx("Only root may add a user or group to the system.\n")) if ($> != 0);
+dief (gtx("Only root may add a user or group to the system.\n")) if ($> != 0);
if( defined($configfile) ) { @defaults = ($configfile); }
@@ -149,12 +154,12 @@
}
if ( (! defined $names[0]) || length($names[0]) == 0 || @names > 2) {
- dief ("$0: ",gtx("Only one or two names allowed.\n"));
+ dief (gtx("Only one or two names allowed.\n"));
}
if (@names == 2) { # must be addusertogroup
- dief ("$0: ",gtx("Specify only one name in this mode.\n"))
+ dief (gtx("Specify only one name in this mode.\n"))
if ($action eq "addsysuser" || $found_group_opt);
$action = "addusertogroup";
$existing_user = shift (@names);
@@ -170,18 +175,18 @@
if ($action ne "addgroup" &&
defined($found_group_opt) +defined($ingroup_name) +defined($new_gid) > 1 ) {
- dief ("$0: ",gtx("The --group, --ingroup, and --gid options are mutually exclusive.\n"));
+ dief (gtx("The --group, --ingroup, and --gid options are mutually exclusive.\n"));
}
if ((defined($special_home)) && ($special_home !~ m+^/+ )) {
- (dief "$0: ",gtx("The home dir must be an absolute path.\n"))
+ (dief (gtx("The home dir must be an absolute path.\n")));
}
if (defined($special_home) && $verbose) {
- print "$0: ",gtx("Warning: The home dir you specified already exists.\n")
+ print "$0: " . gtx("Warning: The home dir you specified already exists.\n")
if (!defined($no_create_home) && -d $special_home);
- print "$0: ",gtx("Warning: The home dir you specified does not exist.\n")
+ print "$0: " . gtx("Warning: The home dir you specified does not exist.\n")
if (defined($no_create_home) && ! -d $special_home);
}
@@ -746,7 +751,7 @@
my ($name) = @_;
if ($name !~ /^[_.A-Za-z0-9][-_.A-Za-z0-9]*\$?$/) {
print STDERR
-("$0: ",gtx("To avoid problems, the username should consist of
+("$0: " . gtx("To avoid problems, the username should consist of
letters, digits, underscores, periods and dashes, and not start with a
dash (as defined by IEEE Std 1003.1-2001). For compatibility with Samba
machine accounts \$ is also supported at the end of the username\n"));
@@ -758,7 +763,7 @@
}
else {
print STDERR
-("$0: ",gtx("Please enter a username matching the regular expression configured
+("$0: " . gtx("Please enter a username matching the regular expression configured
via the name_regex configuration variable. Use the `--force-badname'
option to relax this check or reconfigure name_regex.\n"));
exit 1;
--
-----------------------------------------------------------------
| ,''`. Stephen Gran |
| : :' : sgran at debian.org |
| `. `' Debian user, admin, and developer |
| `- http://www.debian.org |
-----------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.alioth.debian.org/pipermail/adduser-devel/attachments/20060426/2c411376/attachment-0001.pgp
More information about the Adduser-devel
mailing list