diff options
author | Dani Llewellyn <dani@bowlhat.net> | 2022-05-03 10:01:25 +0100 |
---|---|---|
committer | Simon Lees <simon@simotek.net> | 2023-08-14 00:48:36 +0000 |
commit | 301a1a4772f1f934a22e106ff032c62ef705462b (patch) | |
tree | 84d669de057869241d834a4a45e74404bb869644 | |
parent | 5f14673f62de501043247982cf7cfc4cd8b7cf3a (diff) |
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 <lucyllewy@ubuntu.com>
-rwxr-xr-x | scripts/xdg-settings.in | 4 |
1 files 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`" |