Read Quoted Parameters in Bash

Reading parameters is easy, but how to read parameters with spaces?
We usually wrap them with parenthesis right? But actually how?

1
2
3
4
5
6
7
8
9
10
11
#!/bin/bash

whitespace="[[:space:]]"
for i in "$@"
do
if [[ $i =~ $whitespace ]]
then
i=\"$i\"
fi
echo $i
done

Read Quoted Parameters in Bash
https://rug.al/2018/2018-02-12-read-quoted-parameters-in-bash/
Author
Rugal Bernstein
Posted on
February 12, 2018
Licensed under