Skip to content

Instantly share code, notes, and snippets.

@spotlesstofu
Forked from ryo1kato/perror
Created December 13, 2021 10:55
Show Gist options
  • Save spotlesstofu/d69a5dac769f7b5cc1ab09f4bbae6417 to your computer and use it in GitHub Desktop.
Save spotlesstofu/d69a5dac769f7b5cc1ab09f4bbae6417 to your computer and use it in GitHub Desktop.
perror - bash implementation
#!/bin/bash
errno_headers="/usr/include/asm-generic/errno-base.h /usr/include/asm-generic/errno.h"
print_usage () {
echo "Usage: ${0##*/} ERRNO"
}
case $1 in
[1-9]|[1-9][0-9]|[1-9][0-9][0-9])
grep --no-filename "\<$1\>" $errno_headers
;;
(-h|--help)
print_usage
exit 1
;;
(*)
print_usage
exit 1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment