I have 3 possible status for my bash code.
I am creating a bash command, where I have 3 possible options, using flags I assing to a local variable a value depending on the input parameters, my code depending on the input parameter generates a 1 kind of file, another kind of file or both files.
If to my command I add "-r" parameter I generate 1 kind of file, "red file" , local scripts var take, activeRed = 1
If to my command I add "-f" parameter I generate , "feed file" , activeFeed = 1
If in my command I use "-rf" I generate both files, activeFeed = 1 activeRed = 1
if [[ $activeRef -eq 1 && $activeFeed -eq 1 ]]; then
python donwload_files.py --config config-ref-"$market".yml --path_arg $start
python donwload_files.py --config config-feed-"$market".yml --path_arg $start
elif [ $activeRef -eq 1 ];then
python donwload_files.py --config config-ref-"$market".yml --path_arg $start
elif [ $activeFeed -eq 1 ]; then
python donwload_files.py --config config-feed-"$market".yml --path_arg $start
else
python donwload_files.py --config config-ref-"$market".yml --path_arg $start
python donwload_files.py --config config-feed-"$market".yml --path_arg $start
fi
As you can see I generate a very simply if else loop, but I think there is a more efficient way for proccesing this 3 cases, in stead of this "non-visual" and repeat way.
Any idea about creating a more logical or efficiennt loop?
Aucun commentaire:
Enregistrer un commentaire