Types

detect_type

Detect the apparent type of a value. Classification order (most to least specific): empty, integer, float, bool, string. Note: 0 and 1 classify as integer, not bool.

Example

case "$(detect_type "${var}")" in
  (integer) ...;;
  (float)   ...;;
  (bool)    ...;;
  (empty)   ...;;
  (string)  ...;;
esac

Arguments

  • $1 (string): Value to classify

Exit codes

  • 0: Always

Output on stdout

  • One of: empty, integer, float, bool, string