akaros/scripts/parse_errno.sh
<<
>>
Prefs
   1#!/bin/bash
   2
   3# Read from stdin lines formatted as:
   4#
   5#  #define      EPERM           1       /* Operation not permitted */
   6#  #define      ENOENT          2       /* No such file or directory */
   7#  #define      ESRCH           3       /* No such process */
   8#  #define      EINTR           4       /* Interrupted system call */
   9#  #define      EIO             5       /* I/O error */
  10#
  11# And output them as:
  12#
  13#  [ 1 ] = "Operation not permitted",
  14#  [ 2 ] = "No such file or directory",
  15#  [ 3 ] = "No such process",
  16#  [ 4 ] = "Interrupted system call",
  17#  [ 5 ] = "I/O error",
  18#
  19
  20grep "^#define\sE" | sed 's/\t\+/\t/g' | cut -f 3- | grep -v "^E" | awk '{printf "\t[ %s ] = \"", $1; for (i=3; i<NF-1; i++) printf "%s ", $i; printf "%s", $(NF-1); printf "\",\n"}'
  21