A bug in the IOS “section” filter

The section filter of the show commands contains a nasty bug (at least in the IOS release 12.4T) in IOS release 12.2SRC: if a line in the section matches the same regular expression as the section header, the rest of the section is not printed. I guess this sounds a bit perplexing, so here's an example. When using the router bgp regular expression in a section filter appended to the show running command, the whole BGP configuration is displayed:
PE-A#show run ¦ section router bgp
router bgp 65000
template peer-policy Internal
send-community both
exit-peer-policy
!
template peer-session Internal
remote-as 65000
update-source Loopback0
exit-peer-session
!
no synchronization
bgp log-neighbor-changes
neighbor 10.0.1.5 inherit peer-session Internal
neighbor 10.0.1.5 description PE-C(RR)
neighbor 10.0.1.5 inherit peer-policy Internal
no auto-summary
!
address-family vpnv4
neighbor 10.0.1.5 activate
neighbor 10.0.1.5 send-community extended
exit-address-family
However, if you use bgp as the regular expression, the printout starts with the router bgp command, but stops abruptly after the first line containing the string bgp, skipping the rest of the section:
PE-A#show run ¦ section bgp
router bgp 65000
template peer-policy Internal
send-community both
exit-peer-policy
!
template peer-session Internal
remote-as 65000
update-source Loopback0
exit-peer-session
!
no synchronization
bgp log-neighbor-changes

10 comments:

  1. How about using ^ in regexp to avoid this condition?
    show running-config | section ^router bgp
  2. Sure you can, even the 'router bgp' without the caret would work; I wanted to point out the behavior when the section header as well as a line in the section match the same regular expression.
  3. 1. This bug is specific to your platform/version - in my lab it isn't reproductible:

    lab01#sh run | section bgp
    router bgp 65519
    no synchronization
    bgp router-id 172.16.0.1
    bgp log-neighbor-changes
    redistribute connected
    redistribute static
    no auto-summary
    snmp-server enable traps bgp
  4. 2. Maybe for this purpose this command has extended syntax:

    lab01#show running-config | section ?
    LINE Regular Expression
    exclude Exclude entire section(s) of output
    include Include entire section(s) of output

    lab01#show running-config | section
  5. I'm also unable to produce this, running 12.4(6)T11 on an 1801.
  6. My fault ... it was 12.2SRC. Fixed the post. Thanks for all the comments, you guys are great!
  7. Question to the owner of 1801 running 12.4(6)T11 :
    which version of adsl microcode you use?
  8. Ivan, I see the same issue here, so I created CSCsq16838 for you. Cheers.
  9. @Xavier: You're fantastic. Thanks.

    Looks like there is still an easy way to submit bug reports to Cisco :) Something I've been hoping to find for the last 10 years :))
  10. fix ready, waiting for commit
Add comment
Sidebar