I have to to parse a query string in bash; I found many solutions online, but I've a big problem when the the asterisk is a "value" o "key".
1 - Example that works
$ PARAMS="key1=val1&key2=val2&key3=val3&key4=val4"
$ ARRAY=(${PARAMS//[=&]/ })
$ echo ${ARRAY[@]}
key1 val1 key2 val2 key3 val3 key4 val4
$
2 - Example that does not work (key4 is equal to *)
$ PARAMS="key1=val1&key2=val2&key3=val3&key4=*"
$ ARRAY=(${PARAMS//[=&]/ })
$ echo ${ARRAY[@]}
key1 val1 key2 val2 key3 val3 key4 file.txt file2.txt file3.txt ...
$
The problem is that the asterisk (*) represent all files in the working directory.
Is the a way to solve this problem? Thank you