RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login

    inifuncs.sh: use basic regular expression match in iniset ?

    Scheduled Pinned Locked Moved Ideas and Development
    iniconfigretropie setupusability
    3 Posts 2 Posters 457 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • LolonoisL
      Lolonois
      last edited by

      I was wondering what contradicts the usage of basic regular expressions in the iniset function [1].

      This would allow the characters +()| to be used as keys (e.g. in emulators.cfg and in turn for selecting an emulator (represented by that key) in runcommand menu. A specific switch or enabled feature for an emulator could be designated with a + sign).

      Currently it is possible to use +() aso. but: The beforementioned [1] egrep fails in detection and in turn a second key-value pair is added to the "ini file" (emulators.cfg for example) if such key entry exists already: iniset performs an add instead of an update.

      I have run a few tests with this change and it works okay:

      diff --git a/scriptmodules/inifuncs.sh b/scriptmodules/inifuncs.sh
      index dea846fc..8d407e0b 100644
      --- a/scriptmodules/inifuncs.sh
      +++ b/scriptmodules/inifuncs.sh
      @@ -63,7 +63,7 @@ function iniProcess() {
       
           local match
           if [[ -f "$file" ]]; then
      -        match=$(egrep -i "$match_re" "$file" | tail -1)
      +        match=$(grep -i "$match_re" "$file" | tail -1)
           else
               touch "$file"
           fi
      
      

      By reviewing the iniset usage where a variable is used as key (and not a static text) I could not identify a regression with this change.

      Is this change useful to put upstream?

      [1] https://github.com/RetroPie/RetroPie-Setup/blob/3e3fd25e9efab7dc392e13f57c1691a547ef57d8/scriptmodules/inifuncs.sh#L66

      BuZzB 1 Reply Last reply Reply Quote 0
      • BuZzB
        BuZz administrators @Lolonois
        last edited by

        @lolonois I'll have to look into this to remind myself, but don't have much time at the moment. But feel free to open a PR and we can discuss.

        To help us help you - please make sure you read the sticky topics before posting - https://retropie.org.uk/forum/topic/3/read-this-first

        1 Reply Last reply Reply Quote 0
        • LolonoisL
          Lolonois
          last edited by

          Sure, no need for a hurry.

          https://github.com/RetroPie/RetroPie-Setup/pull/3349

          1 Reply Last reply Reply Quote 1
          • First post
            Last post

          Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.

          Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.