Skip to content

Instantly share code, notes, and snippets.

@jmroot
Last active March 1, 2023 03:35
Show Gist options
  • Select an option

  • Save jmroot/2dcb49179e0f97971430f03eba2bf5e9 to your computer and use it in GitHub Desktop.

Select an option

Save jmroot/2dcb49179e0f97971430f03eba2bf5e9 to your computer and use it in GitHub Desktop.
basic PortIndex lint script
#!/usr/bin/env port-tclsh
# check a PortIndex for duplicate portnames and malformed portinfo
set fd [open [lindex $argv 0]]
array set counts {}
while {[gets $fd line] >= 0} {
set name [string tolower [lindex $line 0]]
incr counts($name)
if {$counts($name) > 1} {
puts stderr "Warning: $counts($name) occurrences of $name"
}
array unset portinfo
set len [lindex $line 1]
set infoline [read $fd $len]
if {[catch {array set portinfo $infoline} result]} {
puts stderr "Warning: failed to parse info for ${name}: $result"
puts stderr "Info line for ${name}: $infoline"
}
}
close $fd
#foreach {n c} [array get counts] {
# puts "$n $c"
#}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment