In case of running scripts/decodecode without any parameters in order to give a copy'n'pasted Code line from, for example, email it would parse only first line of it, while in emails it's split to few. ie, when you have a file out of oops the Code line looks like Code: hh hh ... <hh> ... hh\n When copy'n'paste from, for example, email where sender or some middle MTA split it, the line looks like: Code: hh hh ... hh\n hh ... <hh> ... hh\n hh hh ... hh\n The Code line followed by another oops line usually contains characters out of hex digit + space + < + > set. So add logic to join this split back if and only if the following lines have hex digits, or spaces, or '<', or '>' characters. It will be quite unlikely to have a broken input in well formed Oops or dmesg, thus a simple regex is being used.
Showing the changes to scripts (1 of 1 file). Show all
Unified · Split
| @@ -21,12 +21,24 @@ trap cleanup EXIT · 20 unmodified lines | ||
| 21 | 21 | |
| 22 | 22 | T=`mktemp` || die "cannot create temp file" |
| 23 | 23 | code= |
| 24 | +cont= | |
| 24 | 25 | |
| 25 | 26 | while read i ; do |
| 26 | 27 | |
| 27 | 28 | case "$i" in |
| 28 | 29 | *Code:*) |
| 29 | 30 | code=$i |
| 31 | + cont=yes | |
| 32 | + ;; | |
| 33 | +*) | |
| 34 | + [ -n "$cont" ] && { | |
| 35 | + xdump="$(echo $i | grep '^[[:xdigit:]<>[:space:]]\+$')" | |
| 36 | + if [ -n "$xdump" ]; then | |
| 37 | + code="$code $xdump" | |
| 38 | + else | |
| 39 | + cont= | |
| 40 | + fi | |
| 41 | + } | |
| 30 | 42 | ;; |
| 31 | 43 | esac |
| 32 | 44 | |