I'm using dash and I need to create CGI script that will parse the query string and save each value to a variable
OLDIFS=$IFS
// use & as delimeter
IFS='&'
//this will loop the queryString variable
for line in $queryString;
do
//check if the key = action, if the condition was satisfied it will save the line to a variable..
//if the key is equal to type etc. etc.
echo "{$line,1}"
if[{$line,0:7}="action="]
then
cgi_action={$line:8}
elif[{$line:0:5}="type="]
then
cgi_type={$line:6}
fi
done
IFS=$OLDIFS
Im sure that I have errors to get the substring of the line (or string) but please let's focus on the error I get when I put an if statement inside a for loop. What's the correct way to write an if condition inside for loop in dash shell scripting.
Additional info, im using ubuntu 14.04,