DoorControl-CGI/parse_query_string.sh

18 lines
380 B
Bash

#! /bin/bash
# This will parse the variable $QUERY_STRING.
# The values will be stored in an associative array.
# The value for a key will be stored in the array element `${param[<KEY>]}`
saveIFS=$IFS
IFS='=&'
XXQuery_string=($QUERY_STRING)
IFS=$saveIFS
declare -A param
for ((i=0; i<${#XXQuery_string[@]}; i+=2))
do
param[${XXQuery_string[i]}]=${XXQuery_string[i+1]}
done