From 301a1a4772f1f934a22e106ff032c62ef705462b Mon Sep 17 00:00:00 2001 From: Dani Llewellyn Date: Tue, 3 May 2022 10:01:25 +0100 Subject: Ensure POSIX-compliant shell scripting to support DASH Some systems, such as Ubuntu, use DASH to provide `/bin/sh` instead of BASH. This means that we need to use POSIX compliant shell scripting as BASHisms are unsupported in DASH. There are two BASH variable substition instances within the code of `xdg-settings.in` that cause KDE users to be unable to find the current web browser because the script dies when hitting this unsupported code. DASH also doesn't support the BASHism that allows `==` inside `[]` tests. * Replace `${variable:0:1}` with `printf`-based equivalent. * Replace use of `==` with `=` Signed-off-by: Lucy Llewellyn --- scripts/xdg-settings.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/xdg-settings.in b/scripts/xdg-settings.in index ce99019..4276b05 100755 --- a/scripts/xdg-settings.in +++ b/scripts/xdg-settings.in @@ -236,7 +236,7 @@ check_browser_kde() binary="`resolve_kde_browser`" # The browser may contain a relative entry to the binary starting with ! - if [ x"!" == x"${browser:0:1}" ]; then + if [ x"!" = x"$(printf %.1s "$browser")" ]; then # get the full path browser="`binary_to_desktop_file ${browser:1}`" binary="`desktop_file_to_binary $browser`" @@ -600,7 +600,7 @@ check_url_scheme_handler_kde() if [ x"$1" = "mailto" ]; then binary="`read_kde_config emaildefaults PROFILE_Default EmailClient`" # The field may contain a relative entry to the binary starting with ! - if [ x"!" == x"${binary:0:1}" ]; then + if [ x"!" = x"$(printf %.1s "$binary")" ]; then # get the full path desktop_file="`binary_to_desktop_file ${binary:1}`" binary="`desktop_file_to_binary $desktop_file`" -- cgit v1.2.3