Loading ...
Sorry, an error occurred while loading the content.

syntax detection fails for scripts with /usr/bin/env in shebang line

Expand Messages
  • Georg Neis
    From elvis.arf: if knownsyntax(filename) then set! bufdisplay=syntax if os== unix && buflines = 1 then { try 1s/ V^#! *[^ ]* / ([^ ] + ).*/set!
    Message 1 of 1 , Jan 17, 2005
    • 0 Attachment
      From elvis.arf:

      if knownsyntax(filename)
      then set! bufdisplay=syntax
      if os=="unix" && buflines >= 1
      then {
      try 1s/\V^#! *[^ ]*\/\([^ ]\+\).*/set! bufdisplay="syntax \1"/x
      if bufdisplay<<11=="syntax perl"
      then set! bufdisplay="syntax perl"
      if bufdisplay<<12=="syntax tclsh"
      then set! bufdisplay="syntax tcl"
      }

      That causes scripts that use '/usr/bin/env <interpreter>' (i.e. many
      perl and python scripts) in their shebang line to be initialised with
      bufdisplay="syntax env".

      A fix could be a further if-statement:

      if knownsyntax(filename)
      then set! bufdisplay=syntax
      if os=="unix" && buflines >= 1
      then {
      try 1s/\V^#! *[^ ]*\/\([^ ]\+\).*/set! bufdisplay="syntax \1"/x
      if bufdisplay=="syntax env"
      then try 1s/\V^#! *[^ ]*\/[^ ]\+ \([^ ]\+\).*/set! bufdisplay="syntax \1"/x
      if bufdisplay<<11=="syntax perl"
      then set! bufdisplay="syntax perl"
      if bufdisplay<<12=="syntax tclsh"
      then set! bufdisplay="syntax tcl"
      }

      Regards, Georg
      --
      Staebchen nahe seiner Mitte packen. Spitzes Ende im Mund anfeuchten.
      In Zahnzwischenraum einfuehren, stumpfe Seite dicht am Zahnfleisch.
      Vorsichtig hin und her bewegen.
    Your message has been successfully submitted and would be delivered to recipients shortly.