pastebin - collaborative debugging tool
rovema.kpaste.net RSS


SImple Linux kernel boot args (/proc/cmdline) parser
Posted by Anonymous on Tue 10th May 2022 14:58
raw | new post
view followups (newest first): SImple Linux kernel boot args (/proc/cmdline) parser by Anonymous

  1. #!/bin/ksh93
  2.  
  3. #
  4. # simple /proc/cmdline parser
  5. #
  6.  
  7. compound c
  8. typeset -a ar
  9. typeset s
  10. typeset dummy
  11.  
  12. ar=( $(cat /proc/cmdline) )
  13.  
  14. compound -A c.values
  15.  
  16. for s in "${ar[@]}" ; do
  17.         dummy=${s/~(Elr)(.+?)(?:=(.+)|)/}
  18.         print -v .sh.match
  19.        
  20.         case "${#.sh.match[*]}" in
  21.                 '2')
  22.                         c.values[${.sh.match[1]}].name="${.sh.match[1]}"
  23.                         ;;
  24.                 '3')
  25.                         c.values[${.sh.match[1]}].name="${.sh.match[1]}"
  26.                         c.values[${.sh.match[1]}].value="${.sh.match[2]}"
  27.                         ;;
  28.                 *)
  29.                         print -u2 -f $"%s: Parser error\n" "$0"
  30.                         ;;
  31.         esac
  32. done
  33.  
  34. print -v c
  35.  
  36. # EOF.

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at