summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Gianelloni <wolf31o2@gentoo.org>2007-03-07 21:32:37 +0000
committerChris Gianelloni <wolf31o2@gentoo.org>2007-03-07 21:32:37 +0000
commitae84ea45ef8c5f7e4e63d48c6092eaa85b528ae9 (patch)
treedc02714f5e96e759f91a7d29f5712b4afb2f9aa8 /app-admin/superadduser
parentVersion bump wrt bug 165555 and cleanup old (diff)
downloadgentoo-2-ae84ea45ef8c5f7e4e63d48c6092eaa85b528ae9.tar.gz
gentoo-2-ae84ea45ef8c5f7e4e63d48c6092eaa85b528ae9.tar.bz2
gentoo-2-ae84ea45ef8c5f7e4e63d48c6092eaa85b528ae9.zip
Change all instances of [ to [[.
(Portage version: 2.1.2.1)
Diffstat (limited to 'app-admin/superadduser')
-rw-r--r--app-admin/superadduser/ChangeLog6
-rw-r--r--app-admin/superadduser/files/1.0.9/superadduser88
2 files changed, 49 insertions, 45 deletions
diff --git a/app-admin/superadduser/ChangeLog b/app-admin/superadduser/ChangeLog
index 64332adc2229..a7eda505afd6 100644
--- a/app-admin/superadduser/ChangeLog
+++ b/app-admin/superadduser/ChangeLog
@@ -1,6 +1,10 @@
# ChangeLog for app-admin/superadduser
# Copyright 2002-2007 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/app-admin/superadduser/ChangeLog,v 1.37 2007/02/21 19:46:58 peper Exp $
+# $Header: /var/cvsroot/gentoo-x86/app-admin/superadduser/ChangeLog,v 1.38 2007/03/07 21:32:37 wolf31o2 Exp $
+
+ 07 Mar 2007; Chris Gianelloni <wolf31o2@gentoo.org>
+ files/1.0.9/superadduser:
+ Change all instances of [ to [[.
21 Feb 2007; Piotr Jaroszyński <peper@gentoo.org> ChangeLog:
Transition to Manifest2.
diff --git a/app-admin/superadduser/files/1.0.9/superadduser b/app-admin/superadduser/files/1.0.9/superadduser
index 25f70989ba9f..d722d0948fc1 100644
--- a/app-admin/superadduser/files/1.0.9/superadduser
+++ b/app-admin/superadduser/files/1.0.9/superadduser
@@ -97,7 +97,7 @@ defgroup=users
# (we ignore it if it's not at the beginning of the line (i.e. commented out with #))
export recycleUIDMIN="$(grep ^UID_MIN /etc/login.defs | awk '{print $2}' 2>/dev/null)"
# If we couldn't find it, set it to the default of 1000
-if [ -z "$recycleUIDMIN" ]; then
+if [[ -z "$recycleUIDMIN" ]]; then
export recycleUIDMIN=1000 # this is the default from Slackware's /etc/login.defs
fi
@@ -117,7 +117,7 @@ recycleuids=no
# it (even though bash1 is no longer supported on Slackware).
function get_input() {
local output
- if [ "`echo $BASH_VERSION | cut -b1`" = "1" ]; then
+ if [[ "`echo $BASH_VERSION | cut -b1`" = "1" ]]; then
echo -n "${1} " >&2 # fudge for use with bash v1
read output
else # this should work with any other /bin/sh
@@ -132,7 +132,7 @@ function display () {
goose="$(echo $2 | cut -d ' ' -f 2-)" # lop off the prefixed argument useradd needs
echo -n "$1 "
# If it's null then display the 'other' information
- if [ -z "$goose" -a ! -z "$3" ]; then
+ if [[ -z "$goose" -a ! -z "$3" ]]; then
echo "$3"
else
echo "$goose"
@@ -142,19 +142,19 @@ function display () {
# Function to check whether groups exist in the /etc/group file
function check_group () {
local got_error group
- if [ ! -z "$@" ]; then
+ if [[ ! -z "$@" ]]; then
for group in $@ ; do
local uid_not_named="" uid_not_num=""
grep -v "$^" $gfile | awk -F: '{print $1}' | grep "^${group}$" >/dev/null 2>&1 || uid_not_named=yes
grep -v "$^" $gfile | awk -F: '{print $3}' | grep "^${group}$" >/dev/null 2>&1 || uid_not_num=yes
- if [ ! -z "$uid_not_named" -a ! -z "$uid_not_num" ]; then
+ if [[ ! -z "$uid_not_named" -a ! -z "$uid_not_num" ]]; then
echo "- Group '$group' does not exist"
got_error=yes
fi
done
fi
# Return exit code of 1 if at least one of the groups didn't exist
- if [ ! -z "$got_error" ]; then
+ if [[ ! -z "$got_error" ]]; then
return 1
fi
}
@@ -170,21 +170,21 @@ function check_group () {
echo
LOGIN="$1"
needinput=yes
-while [ ! -z $needinput ]; do
- if [ -z "$LOGIN" ]; then
- while [ -z "$LOGIN" ]; do LOGIN="$(get_input "Login name for new user []:")" ; done
+while [[ ! -z $needinput ]]; do
+ if [[ -z "$LOGIN" ]]; then
+ while [[ -z "$LOGIN" ]]; do LOGIN="$(get_input "Login name for new user []:")" ; done
fi
grep "^${LOGIN}:" $pfile >/dev/null 2>&1 # ensure it's not already used
- if [ $? -eq 0 ]; then
+ if [[ $? -eq 0 ]]; then
echo "- User '$LOGIN' already exists; please choose another"
unset LOGIN
- elif [ ! -z "$( echo $LOGIN | grep "^[0-9]" )" ]; then
+ elif [[ ! -z "$( echo $LOGIN | grep "^[0-9]" )" ]]; then
echo "- User names cannot begin with a number; please choose another"
unset LOGIN
- elif [ ! "$LOGIN" = "`echo $LOGIN | tr A-Z a-z`" ]; then # useradd does not allow uppercase
+ elif [[ ! "$LOGIN" = "`echo $LOGIN | tr A-Z a-z`" ]]; then # useradd does not allow uppercase
echo "- User '$LOGIN' contains illegal characters (uppercase); please choose another"
unset LOGIN
- elif [ ! -z "$( echo $LOGIN | grep '\.' )" ]; then
+ elif [[ ! -z "$( echo $LOGIN | grep '\.' )" ]]; then
echo "- User '$LOGIN' contains illegal characters (period/dot); please choose another"
unset LOGIN
else
@@ -193,7 +193,7 @@ while [ ! -z $needinput ]; do
done
# Display the user name passed from the shell if it hasn't changed
-if [ "$1" = "$LOGIN" ]; then
+if [[ "$1" = "$LOGIN" ]]; then
echo "Login name for new user: $LOGIN"
fi
@@ -205,10 +205,10 @@ fi
#
echo
needinput=yes
-while [ ! -z "$needinput" ]; do
+while [[ ! -z "$needinput" ]]; do
_UID="$(get_input "User ID ('UID') [ defaults to next available ]:")"
grep -v "^$" $pfile | awk -F: '{print $3}' | grep "^${_UID}$" >/dev/null 2>&1
- if [ $? -eq 0 ]; then
+ if [[ $? -eq 0 ]]; then
echo "- That UID is already in use; please choose another"
elif [ ! -z "$(echo $_UID | egrep '[A-Za-z]')" ]; then
echo "- UIDs are numerics only"
@@ -217,11 +217,11 @@ while [ ! -z "$needinput" ]; do
fi
done
# If we were given a UID, then syntax up the variable to pass to useradd
-if [ ! -z "$_UID" ]; then
+if [[ ! -z "$_UID" ]]; then
U_ID="-u ${_UID}"
else
# Will we be recycling UIDs?
- if [ "$recycleuids" = "yes" ]; then
+ if [[ "$recycleuids" = "yes" ]]; then
U_ID="-u $(awk -F: '{uid[$3]=1} END { for (i=ENVIRON["recycleUIDMIN"];i in uid;i++);print i}' $pfile)"
fi
fi
@@ -231,17 +231,17 @@ fi
# We check /etc/group for both the text version and the group ID number
echo
needinput=yes
-while [ ! -z "$needinput" ]; do
+while [[ ! -z "$needinput" ]]; do
GID="$(get_input "Initial group [ ${defgroup} ]:")"
check_group "$GID"
- if [ $? -gt 0 ]; then
+ if [[ $? -gt 0 ]]; then
echo "- Please choose another"
else
unset needinput
fi
done
# Syntax the variable ready for useradd
-if [ -z "$GID" ]; then
+if [[ -z "$GID" ]]; then
GID="-g ${defgroup}"
else
GID="-g ${GID}"
@@ -251,12 +251,12 @@ fi
#
echo
needinput=yes
-while [ ! -z "$needinput" ]; do
+while [[ ! -z "$needinput" ]]; do
AGID="$(get_input "Additional groups (comma separated) []:")"
AGID="$(echo "$AGID" | tr -d ' ' | tr , ' ')" # fix up for parsing
- if [ ! -z "$AGID" ]; then
+ if [[ ! -z "$AGID" ]]; then
check_group "$AGID" # check all groups at once (treated as N # of params)
- if [ $? -gt 0 ]; then
+ if [[ $? -gt 0 ]]; then
echo "- Please re-enter the group(s)"
else
unset needinput # we found all groups specified
@@ -271,20 +271,20 @@ done
#
echo
needinput=yes
-while [ ! -z "$needinput" ]; do
+while [[ ! -z "$needinput" ]]; do
HME="$(get_input "Home directory [ ${defhome}/${LOGIN} ]")"
- if [ -z "$HME" ]; then
+ if [[ -z "$HME" ]]; then
HME="${defhome}/${LOGIN}"
fi
# Warn the user if the home dir already exists
- if [ -d "$HME" ]; then
+ if [[ -d "$HME" ]]; then
echo "- Warning: '$HME' already exists !"
getyn="$(get_input " Do you wish to change the home directory path ? (Y/n) ")"
- if [ "$(echo $getyn | grep -i "n")" ]; then
+ if [[ "$(echo $getyn | grep -i "n")" ]]; then
unset needinput
# You're most likely going to only do this if you have the dir *mounted* for this user's $HOME
getyn="$(get_input " Do you want to chown $LOGIN.$( echo $GID | awk '{print $2}') $HME ? (y/N) ")"
- if [ "$(echo $getyn | grep -i "y")" ]; then
+ if [[ "$(echo $getyn | grep -i "y")" ]]; then
CHOWNHOMEDIR=$HME # set this to the home directory
fi
fi
@@ -292,29 +292,29 @@ while [ ! -z "$needinput" ]; do
unset needinput
fi
done
-HME="-d ${HME}"
-
+HME="-d ${HME}"
+
#: Get the new user's shell :#
echo
needinput=yes
-while [ ! -z "$needinput" ]; do
+while [[ ! -z "$needinput" ]]; do
unset got_error
SHL="$(get_input "Shell [ ${defshell} ]")"
- if [ -z "$SHL" ]; then
+ if [[ -z "$SHL" ]]; then
SHL="${defshell}"
fi
# Warn the user if the shell doesn't exist in /etc/shells or as a file
- if [ -z "$(grep "^${SHL}$" $sfile)" ]; then
+ if [[ -z "$(grep "^${SHL}$" $sfile)" ]]; then
echo "- Warning: ${SHL} is not in ${sfile} (potential problem using FTP)"
got_error=yes
fi
- if [ ! -f "$SHL" ]; then
+ if [[ ! -f "$SHL" ]]; then
echo "- Warning: ${SHL} does not exist as a file"
got_error=yes
fi
- if [ ! -z "$got_error" ]; then
+ if [[ ! -z "$got_error" ]]; then
getyn="$(get_input " Do you wish to change the shell ? (Y/n) ")"
- if [ "$(echo $getyn | grep -i "n")" ]; then
+ if [[ "$(echo $getyn | grep -i "n")" ]]; then
unset needinput
fi
else
@@ -326,9 +326,9 @@ SHL="-s ${SHL}"
#: Get the expiry date :#
echo
needinput=yes
-while [ ! -z "$needinput" ]; do
+while [[ ! -z "$needinput" ]]; do
EXP="$(get_input "Expiry date (YYYY-MM-DD) []:")"
- if [ ! -z "$EXP" ]; then
+ if [[ ! -z "$EXP" ]]; then
# Check to see whether the expiry date is in the valid format
if [ -z "$(echo "$EXP" | grep "^[[:digit:]]\{4\}[-]\?[[:digit:]]\{2\}[-]\?[[:digit:]]\{2\}$")" ]; then
echo "- That is not a valid expiration date"
@@ -368,7 +368,7 @@ echo
CMD="$useradd "$HME" -m "$EXP" "$U_ID" "$GID" "$AGID" "$SHL" "$LOGIN""
$CMD
-if [ $? -gt 0 ]; then
+if [[ $? -gt 0 ]]; then
echo "- Error running useradd command -- account not created!"
echo "(cmd: $CMD)"
exit 1
@@ -376,19 +376,19 @@ fi
# chown the home dir ? We can only do this once the useradd has
# completed otherwise the user name doesn't exist.
-if [ ! -z "${CHOWNHOMEDIR}" ]; then
+if [[ ! -z "${CHOWNHOMEDIR}" ]]; then
chown "$LOGIN"."$( echo $GID | awk '{print $2}')" "${CHOWNHOMEDIR}"
fi
# Set the finger information
$chfn "$LOGIN"
-if [ $? -gt 0 ]; then
+if [[ $? -gt 0 ]]; then
echo "- Warning: an error occurred while setting finger information"
fi
# Set a password
$passwd "$LOGIN"
-if [ $? -gt 0 ]; then
+if [[ $? -gt 0 ]]; then
echo "* WARNING: An error occured while setting the password for"
echo " this account. Please manually investigate this *"
exit 1
@@ -396,7 +396,7 @@ fi
# If it was created (it should have been!), set the permissions for that user's dir
HME="$(echo "$HME" | awk '{print $2}')" # We have to remove the -g prefix
-if [ -d "$HME" ]; then
+if [[ -d "$HME" ]]; then
$chmod $defchmod "$HME"
fi