From: downsj Date: Thu, 20 Feb 1997 01:24:17 +0000 (+0000) Subject: Don't add shells multiple times, from tv@pobox.com. PR# user/112. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=2fb3fdcebd88519962fa6c180328ae30cc48a610;p=openbsd Don't add shells multiple times, from tv@pobox.com. PR# user/112. --- diff --git a/usr.sbin/adduser/adduser.perl b/usr.sbin/adduser/adduser.perl index 5f5c9196463..0d7ab32c612 100644 --- a/usr.sbin/adduser/adduser.perl +++ b/usr.sbin/adduser/adduser.perl @@ -1,6 +1,6 @@ #!/usr/bin/perl # -# $OpenBSD: adduser.perl,v 1.2 1996/12/08 13:57:07 downsj Exp $ +# $OpenBSD: adduser.perl,v 1.3 1997/02/20 01:24:17 downsj Exp $ # # Copyright (c) 1995-1996 Wolfram Schneider . Berlin. # All rights reserved. @@ -120,11 +120,11 @@ sub shells_read { # Allow /nonexistent and /bin/date as a valid shell for system utils push(@list, "/nonexistent"); - push(@shellpref, "no"); + &shell_pref_add("no"); $shell{"no"} = "/nonexistent"; push(@list, "/bin/date"); - push(@shellpref, "date"); + &shell_pref_add("date"); $shell{"date"} = "/bin/date"; return $err; @@ -145,7 +145,7 @@ sub shells_add { # found shell if (&confirm_yn("Found shell: $dir/$sh. Add to $etc_shells?", "yes")) { push(@list, "$dir/$sh"); - push(@shellpref, "$sh"); + &shell_pref_add("$sh"); $shell{&basename("$dir/$sh")} = "$dir/$sh"; $changes++; } @@ -156,6 +156,17 @@ sub shells_add { &append_file($etc_shells, @list) if $#list >= 0; } +# add shell to preference list without duplication +sub shell_pref_add { + local($new_shell) = @_; + local($shell); + + foreach $shell (@shellpref) { + return if ($shell eq $new_shell); + } + push(@shellpref, $new_shell); +} + # choose your favourite shell and return the shell sub shell_default { local($e,$i,$new_shell);