Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
openfoam
openfoam
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 334
    • Issues 334
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 6
    • Merge Requests 6
  • Operations
    • Operations
    • Incidents
  • Analytics
    • Analytics
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
  • Development
  • openfoamopenfoam
  • Issues
  • #1757

Closed
Open
Opened Jul 01, 2020 by Mark Olesen@markMaintainer

dash bug with string expansion and assignment of default values

Noticed when compiling OpenFOAM-v2006 modules with ubuntu bionic (18.04) that the module prefix is not being correctly set. Seems to be a weird bug in the dash shell expansions.

Starting from any non-root directory

echo "$PWD"
-> /home/user/openfoam/BuildEnv/scratch

dash 0.5.8-2.10 (bionic) shows this

unset test1
echo "${test1:=${PWD%/*}}"
-> /home/user/openfoam/BuildEnv/scratch  <-- WHAT?? Not what we expected

The additional quotes cause incorrect expansion. Whereas

unset test1
echo ${test1:=${PWD%/*}}
-> /home/user/openfoam/BuildEnv  <-- Expected
  • bash and dash 0.5.10.2-6 (focal) work as expected, with/without quotes
  • quoted expansion with :- works as expected.

Possible fixes?

  • https://git.kernel.org/pub/scm/utils/dash/dash.git/commit/?id=48ca00863af909461d1372998bb90549f27abaaf
  • https://git.kernel.org/pub/scm/utils/dash/dash.git/commit/?id=a29e9a1738a4e7040211842f3f3d90e172fa58ce
  • https://git.kernel.org/pub/scm/utils/dash/dash.git/commit/?id=878514712c5d21f675c45d99d2f8a04098ea4a19

Possible workarounds

  • use unqoted version, but risk fixing it on the next shellcheck
  • explicit if [ -z VAR ]; then ...; fi construct
  • with dirname as : "${VAR:=$(dirname xxx)}
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: Development/openfoam#1757