Skip to content

Commit

Permalink
Make script POSIX compliant
Browse files Browse the repository at this point in the history
Signed-off-by: Nick Roberts <[email protected]>
  • Loading branch information
ncik-roberts committed Nov 30, 2023
1 parent b4c213d commit 827e97b
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions tests/test-dirs/type-enclosing/jane-street.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,26 @@
json that merlin produces can't be parsed by jq, so we use [paste -sd ' ']
to print everything on one line.

$ function run () {
$ run_with_verbosity () {
> file=$1
> position=$2
> line=$(cut -d ':' -f 1 <<< "$position")
> col=$(cut -d ':' -f 2 <<< "$position")
> sed -n ${line}p $file
> printf "%*s^\n" $((col-1)) ''
> function with_verbosity () {
> verbosity=$1
> echo -n "With verbosity $verbosity: "
> $MERLIN single type-enclosing -position $position -verbosity $verbosity \
> -filename $file < $file |
> paste -sd ' ' |
> jq '.value[0].type'
> }
> with_verbosity 0
> with_verbosity 1
> verbosity=$3
> echo -n "With verbosity $verbosity: "
> $MERLIN single type-enclosing -position "$position" -verbosity "$verbosity" \
> -filename "$file" < "$file" |
> paste -sd ' ' |
> jq '.value[0].type'
> }

$ run () {
> file=$1
> position=$2
> line=$(echo "$position" | cut -d ':' -f 1)
> col=$(echo "$position" | cut -d ':' -f 2)
> sed -n "${line}p" "$file"
> printf "%*s^\n" "$(expr $col - 1)" ''
> run_with_verbosity "$file" "$position" 0
> run_with_verbosity "$file" "$position" 1
> echo
> }

Expand Down

0 comments on commit 827e97b

Please sign in to comment.