exercise2 and exercise3, add functions folder

This commit is contained in:
mlot
2026-05-13 14:09:30 -04:00
parent cac0aea0c3
commit 523f4b0809
2 changed files with 37 additions and 0 deletions

19
exit_return_codes/exercise2.sh Executable file
View File

@@ -0,0 +1,19 @@
#!/usr/bin/env bash
FD_NAME=$1
if [ -f $FD_NAME ]
then
echo "${FD_NAME} is a regular file."
exit 0
elif [ -d $FD_NAME ]
then
echo "${FD_NAME} is a regular directory."
exit 1
else
echo "${FD_NAME} is NOT a regular file or directory."
exit 2
fi
# Exit with an explicit exit status.
exit 0

18
exit_return_codes/exercise3.sh Executable file
View File

@@ -0,0 +1,18 @@
#!/usr/bin/env bash
#
# <Replace with the purpose or description of of this shell script.>
#
cat /etc/shadow
if [ "$?" -ne "0" ]
then
echo "Command failed"
exit 1
else
echo "Command succeeded"
exit 0
fi
# Exit with an explicit exit status.
exit 0