From 462d2699fff3f6ea98db82cdfc52052f7d21cc17 Mon Sep 17 00:00:00 2001 From: gitea Date: Fri, 9 Oct 2026 07:57:17 +0200 Subject: [PATCH] Add Function.sh --- Function.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Function.sh diff --git a/Function.sh b/Function.sh new file mode 100644 index 0000000..6f9be1a --- /dev/null +++ b/Function.sh @@ -0,0 +1,24 @@ +#!/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