File: jo.17.sh

package info (click to toggle)
jo 1.9-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 612 kB
  • sloc: ansic: 1,914; sh: 566; makefile: 60; exp: 42
file content (30 lines) | stat: -rw-r--r-- 1,099 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# type coercion

# coerce key=val
for v in "" string \"quoted\" 12345 true false null; do
  ${JO:-jo} -- -s s="$v" -n n="$v" -b b="$v" a="$v"
done

# coerce array items
${JO:-jo} -a -- -s 123 -n "This is a test" -b C_Rocks 456

# coercion flag strings should be usable as inputs, when they aren't flags
${JO:-jo} -a -- -s -s -n -n -b -b

# non-flag strings should be read as normal strings, even if they begin with "-"
${JO:-jo} -a -- --test --toast
${JO:-jo} -- --test=--toast

# coercion is one-shot, so all "--toast" strings are normal input
${JO:-jo} -a -- -b --test --toast -s --test --toast -n --test --toast

### These should NOT be coerced

# @ booleans
for v in 0 1; do
  ${JO:-jo} -- -s s@"$v" -n n@"$v" -b b@"$v" a@"$v"
done

# @/% file inclusions
${JO:-jo} -- -s s=@${srcdir:=.}/tests/jo-creator.txt -n n=@${srcdir:=.}/tests/jo-creator.txt -b b=@${srcdir:=.}/tests/jo-creator.txt a=@${srcdir:=.}/tests/jo-creator.txt
${JO:-jo} -- -s s=%${srcdir:=.}/tests/jo-creator.txt -n n=%${srcdir:=.}/tests/jo-creator.txt -b b=%${srcdir:=.}/tests/jo-creator.txt a=%${srcdir:=.}/tests/jo-creator.txt