Files
Bash/Function.sh
T
2026-10-09 07:57:17 +02:00

25 lines
554 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# Recherche sur saisie la présence de $user dans /etc/passwd
function exist_user {
local VariableLocale="Locale"
VariableGlobale="Globale"
echo "Saisir le nom d’un utilisateur : \c"
read user
if grep -q "^$user": /etc/passwd
then
return 0
fi
return 1
}
if exist_user
then
echo "L’utilisateur $user existe"
exit 0
else
echo -e "\033[0;31m L’utilisateur $user n’est pas defini \033[0m"
exit 1
fi
echo "$VariableLocale" # N’est pas récupérée
echo "$VariableGlobale" # Disponible