~kmaasrud/shatgpt

7040d61572341ae9fd3135b3acde4ce987f08ced — Knut Magnus Aasrud 1 year, 6 months ago 58ebc41
shorten get_field function
1 files changed, 4 insertions(+), 7 deletions(-)

M shatgpt
M shatgpt => shatgpt +4 -7
@@ 96,23 96,20 @@ get_field() {
    tmp="${1#*\"$2\":\"}"
    while [ -n "$tmp" ]; do
      rest="${tmp#?}"
      char="${tmp%"$rest"}"
      c="${tmp%"$rest"}"
      tmp="$rest"
      case $char in
      case $c in
        '"')
          break
        ;;
        '\')
          printf '%s' "$char"
          i=$((i + 1))
          rest="${tmp#?}"
          char="${tmp%"$rest"}"
          c="$char${tmp%"$rest"}"
          tmp="$rest"
        ;;
        *);;
      esac
      printf '%s' "$char"
      i=$((i + 1))
      printf '%s' "$c"
    done
}