=chomp() macro
[posted 2001/11/16]
Here are several fixes for problems you are possibly having with the most recent configs_samples (in PIKT 1.15.0).
For a while, PIKT was finding weird error messages about "'end of file' unexpected" in Urgent.log on Solaris systems. MessagesScanUrgent runs were generating these errors:
DEBUG: PiktUrgentLogScanDebug Scan the PIKT Urgent.log for noteworthy entries sh: syntax error at line 1: `end of file' unexpected sh: syntax error at line 1: `end of file' unexpected sh: syntax error at line 1: `end of file' unexpected
The problem traced to /var/adm/messages lines like
Nov 14 08:43:21 paris6 unix: stdout is </sbus,0/zs,1100000:a> major <29> minor <0>
A pattern match in the 3rd rule of MessagesScanUrgent would intercept such lines and pass them along to the =diskdev() macro for further munging (specifically, to translate device file gobbledygook to human-readable named file systems).
The problem was due to the ">" character in (for example),
/sbus,0/zs,1100000:a>
I might have been able to fix the regexp
|| $inlin =~ "(/sbus\@[[:digit:]][[:graph:]]+)"
to exclude the ">". Instead, I revised the =chomp macro as follows:
/////////////////////////////////////////////////////////////////////////////// chomp(S, C) // sort of like Perl's chomp, chop the last char off of // string S if it's a (C) if $right((S),1) eq (C) set (S) = $chop((S)) fi ///////////////////////////////////////////////////////////////////////////////
Before (before 1.15.0), the =chomp macro was defined just to deal with newlines:
/////////////////////////////////////////////////////////////////////////////// chomp(S) // sort of like Perl's chomp, chop the last char off of // string S if it's a newline if $right((S),1) eq $newline() set (S) = $chop((S)) fi ///////////////////////////////////////////////////////////////////////////////
So now, before passing the line along to =devfile(), I just add a =chomp() instruction before it:
if ( $inlin =~ "(/iommu\@[[:alpha:]][[:graph:]]+)" || $inlin =~ "(/pci\@[[:digit:]][[:graph:]]+)" || $inlin =~ "(/sbus\@[[:digit:]][[:graph:]]+)" || $inlin =~ "(/pseudo/md\@[[:digit:]][[:graph:]]+)" || $inlin =~ "(/io-unit\@[[:alpha:]][[:graph:]]+)" ) set $df = $1 =chomp($df, ">") set $dd = =diskdev($df)
Problem solved!
For more examples, see Developer's Notes.