Add basic support for complex strings
This commit is contained in:
parent
657db23236
commit
2b09cc2e58
13
lib/cli.sh
13
lib/cli.sh
|
@ -41,12 +41,21 @@ parse_ws() {
|
||||||
}
|
}
|
||||||
|
|
||||||
parse_word() {
|
parse_word() {
|
||||||
local arg line=$1
|
local arg line=$1 instr=0
|
||||||
|
|
||||||
while (( ${#line} )); do
|
while (( ${#line} )); do
|
||||||
local next=${line:0:1}
|
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
|
arg+=$next
|
||||||
line=${line:1}
|
line=${line:1}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue