Skip to content

Commit 710dda0

Browse files
committed
Added a function to check if an argument has been passed
1 parent 3b42a2f commit 710dda0

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

argument-parser.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,15 @@ do
9696
echo "ARG: $k = ${args[$k]}"
9797
done
9898

99-
[ ${args["u"]+abc} ] && echo "you passed the -u flag"
99+
argExists() {
100+
if [ ${args["$1"]+abc} ]; then
101+
return 0
102+
else
103+
return 1
104+
fi
105+
}
106+
107+
if argExists 'u'; then
108+
echo "you passed the -u flag"
109+
fi
100110

0 commit comments

Comments
 (0)