I've some string inputted by user such as:
read -p "define module tags (example: TAG1, TAG2): " -r module_tags
if [ "$module tags" = "" ]; then module tags="TAG1, TAG2"; fi
which are tags separated by ,
Than, I need to append these tags in a JSON array field:
{
"modules": [
{
"tags": "<user-custom-tags>"
}
]
}
I would do it in this way:
args='.modules[0].tags = '$module_tags''
tmp=$(mktemp -u)
jq --indent 4 "$args" $plugin_file > "$tmp" && mv "$tmp" $plugin_file
But for this, I need to transform the input TAG1, TAG2
to [ "TAG1", "TAG2" ]
How would you do this?