Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
Merge pull request #24 from Antiz96/rename_var
Browse files Browse the repository at this point in the history
Rename the 'argument' var to 'option'
  • Loading branch information
Antiz96 authored Jun 9, 2023
2 parents cf57dd8 + b975948 commit 5cf2004
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Options:
Exit Codes:
0 OK
1 Invalid argument/option
1 Invalid option
2 User didn't gave the confirmation to proceed
3 An error occured when creating/restoring the backup of the .bashrc file
4 An error occured when adding/removing the alias
Expand Down
2 changes: 1 addition & 1 deletion doc/man/malias.1
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ OK

.TP
.B 1
Invalid argument/option
Invalid option

.TP
.B 2
Expand Down
34 changes: 17 additions & 17 deletions src/script/malias.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

# Variables definition
name="malias"
version="1.2.3"
argument="${1}"
version="1.2.4"
option="${1}"

# Definition of the help function: Print the help message
help() {
Expand All @@ -33,9 +33,9 @@ version() {
echo "${name} ${version}"
}

# Definition of the invalid_argument function: Print an error message, ask the user to check the help and exit
invalid_argument() {
echo -e >&2 "${name}: invalid argument -- '${argument}'\nTry '${name} --help' for more information."
# Definition of the invalid_option function: Print an error message, ask the user to check the help and exit
invalid_option() {
echo -e >&2 "${name}: invalid option -- '${option}'\nTry '${name} --help' for more information."
exit 1
}

Expand Down Expand Up @@ -102,28 +102,28 @@ help (Print the help)
quit (Quit Malias)
EOF

read -rp $'\nWhat operation do you want to do? ' argument
argument=$(echo "${argument}" | awk '{print tolower($0)}')
read -rp $'\nWhat operation do you want to do? ' option
option=$(echo "${option}" | awk '{print tolower($0)}')

case "${argument}" in
case "${option}" in
a|add)
argument="--add"
option="--add"
;;
l|list)
argument="--list"
option="--list"
;;
d|delete)
argument="--delete"
option="--delete"
;;
h|help)
argument="--help"
option="--help"
;;
q|quit)
echo -e "\nGoodbye !"
exit 0
;;
*)
invalid_argument
invalid_option
;;
esac

Expand Down Expand Up @@ -207,14 +207,14 @@ delete() {
fi
}

# Execute the different functions depending on the argument
case "${argument}" in
# Execute the different functions depending on the option
case "${option}" in
-m|--menu|"")
menu
;;
esac

case "${argument}" in
case "${option}" in
-a|--add)
add
;;
Expand All @@ -231,6 +231,6 @@ case "${argument}" in
version
;;
*)
invalid_argument
invalid_option
;;
esac

0 comments on commit 5cf2004

Please sign in to comment.