fix comma quoting in tup/tupx by quoting all commas
This commit is contained in:
parent
68125ee7d8
commit
cba3556da8
2 changed files with 6 additions and 3 deletions
|
@ -262,7 +262,7 @@ tup() {
|
||||||
read arg
|
read arg
|
||||||
tup $arg
|
tup $arg
|
||||||
else
|
else
|
||||||
list "$@" | map lambda x . 'echo ${x/,/u002c}' | join , '(' ')'
|
list "$@" | map lambda x . 'echo ${x//,/u002c}' | join , '(' ')'
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,7 +274,7 @@ tupx() {
|
||||||
else
|
else
|
||||||
local n=$1
|
local n=$1
|
||||||
shift
|
shift
|
||||||
echo "$@" | stripl '(' | stripr ')' | cut -d',' -f${n} | tr ',' '\n' | map lambda x . 'echo ${x/u002c/,}'
|
echo "$@" | stripl '(' | stripr ')' | cut -d',' -f${n} | tr ',' '\n' | map lambda x . 'echo ${x//u002c/,}'
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ testTupIfOneElement() {
|
||||||
assertEquals '(")' $(tup '"')
|
assertEquals '(")' $(tup '"')
|
||||||
assertEquals "(')" $(tup "'")
|
assertEquals "(')" $(tup "'")
|
||||||
assertEquals "(u002c)" $(tup ",")
|
assertEquals "(u002c)" $(tup ",")
|
||||||
|
assertEquals "(u002cu002c)" $(tup ",,")
|
||||||
assertEquals "(()" $(tup "(")
|
assertEquals "(()" $(tup "(")
|
||||||
assertEquals "())" $(tup ")")
|
assertEquals "())" $(tup ")")
|
||||||
}
|
}
|
||||||
|
@ -38,6 +39,7 @@ testTupxIfZeroIndex() {
|
||||||
|
|
||||||
testTupxIfSpecialChars() {
|
testTupxIfSpecialChars() {
|
||||||
assertEquals ',' "$(tup ',' | tupx 1)"
|
assertEquals ',' "$(tup ',' | tupx 1)"
|
||||||
|
assertEquals ',,' "$(tup ',,' | tupx 1)"
|
||||||
assertEquals '(' "$(tup '(' | tupx 1)"
|
assertEquals '(' "$(tup '(' | tupx 1)"
|
||||||
assertEquals ')' "$(tup ')' | tupx 1)"
|
assertEquals ')' "$(tup ')' | tupx 1)"
|
||||||
assertEquals '()' "$(tup '()' | tupx 1)"
|
assertEquals '()' "$(tup '()' | tupx 1)"
|
||||||
|
@ -45,6 +47,7 @@ testTupxIfSpecialChars() {
|
||||||
assertEquals '(' "$(tup '(' '(' | tupx 1)"
|
assertEquals '(' "$(tup '(' '(' | tupx 1)"
|
||||||
assertEquals ')' "$(tup ')' ')' | tupx 1)"
|
assertEquals ')' "$(tup ')' ')' | tupx 1)"
|
||||||
assertEquals ',' "$(tup 'u002c' | tupx 1)"
|
assertEquals ',' "$(tup 'u002c' | tupx 1)"
|
||||||
|
assertEquals ',,' "$(tup 'u002cu002c' | tupx 1)"
|
||||||
}
|
}
|
||||||
|
|
||||||
testTupxRange() {
|
testTupxRange() {
|
||||||
|
|
Loading…
Reference in a new issue