Menu

#244 Marking in sh mode fails completely or is useless

9.2.2
closed
nobody
Mark (1)
Bug
Tools
minor
2021-03-07
2021-01-14
No

The sh mode does no longer mark my shell scripts properly. If sh mode pref "Mark Headers Only" is false, lines starting at the leftmost position are listed, but all actual headers are ignored. If sh mode pref "Mark Headers Only" is true, nothing is marked, while my files are full of headers, also at various hierarchical levels. I am not sure whether this annoying behavior of the mode is a bug or not. I use no sh mode specific tcl file. I am working basically with default settings.

Discussion

  • Bernard Desgraupes

    Hi Andreas,
    thank you for reporting this. I am not the author of the sh mode in Alpha but I had a look at the code. Could you explain exactly what you would expect regarding file marking in sh mode ?
    We are speaking here of the sh mode (shell scripts mode). Note that there is also a bash mode and a zsh mode in Alpha: their marking scheme is less complex than what sh mode does.

     
    • Fischlin Andreas

      Dear Bernard,

      I guess an excerpt should demonstrate what I mean:

      ____ BEGIN OF shell script EXCERPT ______
      echo " Hint: Use command 'switch2using -v' to learn about RASS environment variables"
      fi
      fi # end of big if for se-server

      4.7 - Done?

      if [ "$onlyInfo" = TRUE ]; then
      # only info wanted
      CleanupAndExit 0
      fi

      ==============================================================================

      5. Test preconditions for possible switching

      ==============================================================================

      5.0 - Option consistency

      optionsConsistent=TRUE

      Compiler (P1 9.0.x is to be favored over 8.2, which is to be favored over 8.3 and 8.4)

      if [ "${useP190}" = TRUE ]; then
      if [ "$useP182" = TRUE ]; then
      if [ "${onlyInfo}" = FALSE ] && [ ${verboseMode} = TRUE ]; then
      ____ END OF shell script EXCERPT ______

      Under AlphaX with mode pref 'mark headers only' the mode did mark

      ____ BEGIN OF expected Marking ______

      4.7 - Done?

      5. Test preconditions for possible switching

      5.0 - Option consistency

      ____ END OF expected Marking ______

      and I could easily jump to any of these locations. Under Alpha the very same mode does either produce nothing (mark headers only checked)

      ____ BEGIN OF actual Marking ___
      __ END OF actual Marking _____

      or merely junk, i.e. all top level statements. In above case for the excerpt:

      ____ BEGIN OF actual Marking ___
      if [ "$onlyInfo" = TRUE ]; then
      optionsConsistent=TRUE
      if [ "${useP190}" = TRUE ]; then
      __ END OF actual Marking _____

      So for pref 'mark headers only’ the marking seems broken (it should also include headers of course) and for pref setting ‘mark headers only’ off, it should mark the headers. I need the latter for my very long shell scripts to get an overview and to be able to jump to the wanted section.

      Note, I do not use automark. The reported behavior is the result of any manual request to mark the file. I rarely use automark, if at all.

      Merci.

      Andreas

       

      Last edit: Bernard Desgraupes 2021-02-03
  • Bernard Desgraupes

    Hi Andreas,

    I just had a look at this marking issue. There is a silly error in the proc sh::MarkFile (in file shScriptsMode.tcl). At line 680, replace

    set pat {^(###{3,4}[\t ]+}
    

    by

    set pat {^(#{3,4}[\t ]+}
    

    and everything is back in order.

    By the way, I agree with you that marking all the statements of a script (when Mark Headers Only is not checked) is absurd and useless. I'll try to find a more useful marking policy (maybe only the flow control keywords like if, for, until, while which correspond to a logical organization of the code). What do you think ?

     
  • Bernard Desgraupes

    This is fixed now.
    Changes committed to the repository (rev. 1995).

     
  • Bernard Desgraupes

    • status: open --> fixed
     
  • Bernard Desgraupes

    • status: fixed --> closed
    • Version: 9.2 --> 9.2.2
     

Log in to post a comment.