#!/usr/app/TurboShell/bin/bash
# return ustawia kod wyjścia funkcji, więc if może go sprawdzić
is_number() {
  [[ $1 =~ ^-?[0-9]+$ ]]
}

level() {
  local used=$1
  ((used < 80)) && return 0
  ((used < 95)) && return 1
  return 2
}

for used in 75 93 97 dużo; do
  if ! is_number "$used"; then
    echo "$used: to nie liczba"
    continue
  fi
  level "$used"
  echo "$used: poziom $?"
done
