Add basic support for complex strings

This commit is contained in:
Nicholas Chambers 2020-05-02 16:01:21 -05:00
parent 657db23236
commit 2b09cc2e58
1 changed files with 11 additions and 2 deletions

View File

@ -41,12 +41,21 @@ parse_ws() {
}
parse_word() {
local arg line=$1
local arg line=$1 instr=0
while (( ${#line} )); do
local next=${line:0:1}
if [[ $next != [[:space:]] ]]; then
if ! (( instr )) && [[ $next = \" ]]; then
instr=1
line=${line:1}
elif (( instr )) && [[ $next = \" ]]; then
instr=0
line=${line:1}
elif (( instr )); then
arg+=$next
line=${line:1}
elif [[ $next != [[:space:]] ]]; then
arg+=$next
line=${line:1}
else