Skip to content
Snippets Groups Projects

Ensure POSIX-compliant shell scripting to support DASH

Merged Lucy Llewellyn requested to merge lucyllewy/xdg-utils:issue-10 into master
2 unresolved threads

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 =

Fixes #10 (closed), #203 (closed)

Signed-off-by: Lucy Llewellyn lucyllewy@ubuntu.com

Edited by Lucy Llewellyn

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
234 234 binary="`resolve_kde_browser`"
235 235
236 236 # The browser may contain a relative entry to the binary starting with !
237 if [ x"\!" == x"$(printf %.1s "$browser")" ]; then
237 if [ x"!" = x"$(printf %.1s "$browser")" ]; then
  • It's maybe worth noting in the commit message that == is a non-portable alias in bash that is exactly identical to =.

    Personally, I'm disappointed that it even exists in bash -- it doesn't really do anything other than confuse people, I strongly recommend using = even in bash scripts.

    ...

    Anyway, it is incorrect to mention Ubuntu, or alternatively, the commit message should probably say "systems such as Ubuntu". There are certainly other systems where the sh shell is dash or another non-bash shell. :)

  • Please register or sign in to reply
  • Simon Lees
  • Also Fixes #203 (closed), let me see if I can add that to the overview to auto close that bug

  • Simon Lees changed the description

    changed the description

  • Simon Lees mentioned in issue #165 (closed)

    mentioned in issue #165 (closed)

  • Lucy Llewellyn added 1 commit

    added 1 commit

    • a114fc51 - Ensure POSIX-compliant shell scripting to support DASH

    Compare with previous version

  • Lucy Llewellyn changed title from Replace BASH substitutions with printf to Ensure POSIX-compliant shell scripting to support DASH

    changed title from Replace BASH substitutions with printf to Ensure POSIX-compliant shell scripting to support DASH

  • Lucy Llewellyn changed the description

    changed the description

  • Author Contributor

    I've squished the commits and reworded the commit message and the description here.

  • Simon Lees added 24 commits

    added 24 commits

    Compare with previous version

  • merged

  • Merged, thanks for your work.

  • Please register or sign in to reply
    Loading