I have to write a bash script that ignores specific strings in variables to prevent file mixups. I am very new to bash and I have no idea how to make a line of code that checks for illegal variable/string combinations.
For example the strings marble
and igneous_rocks
should never be used together in a for loop. This is the code that needs to be changed:
#!/bin/bash
IGNEOUS_BLOCK=(aa adakite pahoehoe)
METAMORPHIC_BLOCK=(eclogite marble)
SEDIMENTARY_BLOCK=(argillite chalk jaspillite)
ROCK_TYPE=(igneous_rocks metamorphic_rocks sedimentary_rocks)
#Buttons
for igneous_block in "${IGNEOUS_BLOCK[@]}" ; do
for rock_type in "${ROCK_TYPE[@]}" ; do
printf "{
\"parent\": \"block/button\",
\"textures\": {
\"texture\": \"strata:blocks/"$rock_type"/"$igneous_block"\"
}
}"> "${igneous_block}_button.json"
done;
done;
This is what it should do:
If the varible ROCK_TYPE
uses the string igneous_rocks
it should only pick strings inside IGNEOUS_BLOCK
and not from METAMORPHIC_BLOCK
and SEDIMENTARY_BLOCK
This is what I want all the variables work:
ROCK_TYPE
cycles through the strings available.
ROCK_TYPE=(igneous_rocks metamorphic_rocks sedimentary_rocks)
IGNEOUS_BLOCK
should only be allowed use the string igneous_rocks
.
IGNEOUS_BLOCK=(aa adakite pahoehoe)
METAMORPHIC_BLOCK
should only be allowed use the string metamorphic_rocks
.
METAMORPHIC_BLOCK=(aa adakite pahoehoe)
SEDIMENTARY_BLOCK
should only be allowed use the string sedimentary_rocks
.
SEDIMENTARY_BLOCK=(aa adakite pahoehoe)
What needs to change in my code to make it work like I want it to?