Results 1 to 4 of 4

Thread: Modify XML syntax higlighting file sh to deal with bash in gedit, pluma, etc.

  1. #1
    Join Date
    May 2008
    Location
    United Kingdom
    Beans
    4,595
    Distro
    Lubuntu 18.04 Bionic Beaver

    Question Modify XML syntax higlighting file sh to deal with bash in gedit, pluma, etc.

    I wonder if you could help me with something that has frustrated me for some time.

    There are many XML files for syntax highlighting for use with editors, e.g. gedit and pluma, in the shared area:
    /usr/share/gtksourceview-3.0/language-specs

    There isn't one for Bash. Most of the time, the workaround is to use the sh syntax highlighting, but there are a couple of problems with using it for Bash. The worst one that I've come across is where command substitution, using quotes, is used within a case block. An example follows:
    Code:
    #!/bin/bash
    
    case ${SOMETHING} in
        ( 'a' )
            FILENAME="$( readlink "${ARG}" )"
            ;;
    esac
    CONFUSING_LINE="case esac"
    If you put this into gedit with the sh syntax highlighting, you'll notice that everything after the readlink command is shown as being in quotes — apart from sections that actually are within quotes!

    Having this structure in a long script file leads to the syntax highlighting after this point being useless. Well, worse than useless, because it incorrectly highlights quoted content.

    So…

    I decided that I'd copy the existing sh.lang to bash.lang, and modify it to work with Bash. It didn't take me long to realise that, despite the file being quite short, I was hopelessly lost. I cannot get my head around how to fix this!

    Can you help, please? I'd love to finally fix this and submit it for the many people who have also asked about Bash highlighting in gedit and other editors.

    Thank you

  2. #2
    Join Date
    May 2007
    Beans
    202
    Distro
    Xubuntu

    Re: Modify XML syntax higlighting file sh to deal with bash in gedit, pluma, etc.

    I've just tried your code in Mousepad and I couldn't make heads or tail of it. But Mousepad has a lot of options for marking code/script.
    Any follow-up information on your issue would be appreciated. Please have the courtesy to report back.

  3. #3
    Join Date
    Jan 2017
    Beans
    135

    Re: Modify XML syntax higlighting file sh to deal with bash in gedit, pluma, etc.

    Works fine on my system with the latest sh.lang file from here: https://gitlab.gnome.org/GNOME/gtkso...language-specs

    gedit.png

  4. #4
    Join Date
    May 2008
    Location
    United Kingdom
    Beans
    4,595
    Distro
    Lubuntu 18.04 Bionic Beaver

    Re: Modify XML syntax higlighting file sh to deal with bash in gedit, pluma, etc.

    Quote Originally Posted by norobro View Post
    Works fine on my system with the latest sh.lang file from here: https://gitlab.gnome.org/GNOME/gtkso...language-specs
    That's fantastic, thank you! I shall make a note of that link in case of future problems.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •