Is it possible to improve the code of this bash script? ... or should I just use another language? (If so, which one would fit the best the situation, according to you?)
Here is the code (simplified, to emphasis the problem):
#!/bin/bash
# mountDDE mount the partitions of the disk b.
# If arguments are passed, it will mount the specific partitions, a, b or c.
if [ -v "$1" ] # If no argument is passed, act on all partitions.
then a=t
b=t
c=t
fi
while [ -n "$1" ] ; do
if [ $1="a" ] # We test the argument(s), to know which partition has to be mounted.
then a=t
elif [ $1="b"] # I hate redundunces
then b=t
elif [ $1="c"] # Again...
then c=t
fi
shift
done
[ $a="t" ] && sudo mount /dev/sba /media/ba # I'll actually use uuids.
[ $b="t" ] && sudo mount /dev/sbb /media/bb # Not direct paths, like here.
[ $c="t" ] && sudo mount /dev/sbc /media/bc
To me, this code is redundant. Is there any more efficient/better way to do it ? Which language should I use for this task?