~dricottone/my-utils

ref: 86e36bedac92f051a285f01385f38446a71db9a6 my-utils/is-int.sh -rwxr-xr-x 250 bytes
86e36bedDominic Ricottone Small fixes recommended by shellcheck 5 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/sh

# is-int.sh
# =========
# Usage: is-int.sh ITEM
#
# Check if an item is an integer.

err_msg() {
  (>&2 echo "$1")
  exit 1
}

if [ $# -lt 1 ]; then
  err_msg "Usage: is-int.sh ITEM"
fi

[ "$1" -eq "$1" ] 2> /dev/null && exit 0 || exit 1