Skip to content
  • Peter Maydell's avatar
    65842b03
    configure: Don't use bash-specific string-replacement syntax · 65842b03
    Peter Maydell authored
    
    
    The variable string-replacement syntax ${var/old/new} is a bashism
    (though it is also supported by some other shells), and for instance
    does not work with the NetBSD /bin/sh, which complains:
     ../src/configure: 687: Syntax error: Bad substitution
    
    Replace it with a more portable sed-based approach, similar to
    what we already do in quote_sh().
    
    Note that shellcheck also diagnoses this:
    
    In ./configure line 687:
        e=${e/'\'/'\\'}
          ^-----------^ SC2039: In POSIX sh, string replacement is undefined.
               ^-- SC1003: Want to escape a single quote? echo 'This is how it'\''s done'.
                    ^-- SC1003: Want to escape a single quote? echo 'This is how it'\''s done'.
    
    In ./configure line 688:
        e=${e/\"/'\"'}
          ^----------^ SC2039: In POSIX sh, string replacement is undefined.
    
    Fixes: 8154f5e6 ("meson: Prefix each element of firmware path")
    Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
    Tested-by: default avatarThomas Huth <thuth@redhat.com>
    Message-id: 20220720152631.450903-4-peter.maydell@linaro.org
    65842b03
    configure: Don't use bash-specific string-replacement syntax
    Peter Maydell authored
    
    
    The variable string-replacement syntax ${var/old/new} is a bashism
    (though it is also supported by some other shells), and for instance
    does not work with the NetBSD /bin/sh, which complains:
     ../src/configure: 687: Syntax error: Bad substitution
    
    Replace it with a more portable sed-based approach, similar to
    what we already do in quote_sh().
    
    Note that shellcheck also diagnoses this:
    
    In ./configure line 687:
        e=${e/'\'/'\\'}
          ^-----------^ SC2039: In POSIX sh, string replacement is undefined.
               ^-- SC1003: Want to escape a single quote? echo 'This is how it'\''s done'.
                    ^-- SC1003: Want to escape a single quote? echo 'This is how it'\''s done'.
    
    In ./configure line 688:
        e=${e/\"/'\"'}
          ^----------^ SC2039: In POSIX sh, string replacement is undefined.
    
    Fixes: 8154f5e6 ("meson: Prefix each element of firmware path")
    Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
    Tested-by: default avatarThomas Huth <thuth@redhat.com>
    Message-id: 20220720152631.450903-4-peter.maydell@linaro.org
Loading