Public bug reported: The following substring expansion to get the first word of a string separated by spaces doesn't work using dash 0.5.8-2.10 on Ubuntu 18.04 LTS:
string="one two three four" first="${string%%' '*}" printf "%s\n" "$first" It prints "one two three four", instead of "one". This works on bash and Solaris sh, but not in dash. Oddly, not putting the white space between single quotes works: string="one two three four" first="${string%% *}" printf "%s\n" "$first" # Prints "one" ** Affects: dash (Ubuntu) Importance: Undecided Status: New ** Tags: bionic ** Tags added: bionic ** Summary changed: - Parameter expansion "${string%%' '*}" doesn't work + Substring expansion "${string%%' '*}" doesn't work ** Description changed: - The following parameter expansion to get the first word of a string + The following substring expansion to get the first word of a string separated by spaces doesn't work using dash 0.5.8-2.10 on Ubuntu 18.04 LTS: string="one two three four" first="${string%%' '*}" printf "%s\n" "$first" It prints "one two three four", instead of "one". This works on bash and Solaris sh, but not in dash. ** Description changed: The following substring expansion to get the first word of a string separated by spaces doesn't work using dash 0.5.8-2.10 on Ubuntu 18.04 LTS: string="one two three four" first="${string%%' '*}" printf "%s\n" "$first" It prints "one two three four", instead of "one". This works on bash and Solaris sh, but not in dash. + + Oddly, not putting the white space between single quotes works: + string="one two three four" + first="${string%% *}" + printf "%s\n" "$first" # Prints "one" -- You received this bug notification because you are a member of Ubuntu Touch seeded packages, which is subscribed to dash in Ubuntu. https://bugs.launchpad.net/bugs/1833817 Title: Substring expansion "${string%%' '*}" doesn't work Status in dash package in Ubuntu: New Bug description: The following substring expansion to get the first word of a string separated by spaces doesn't work using dash 0.5.8-2.10 on Ubuntu 18.04 LTS: string="one two three four" first="${string%%' '*}" printf "%s\n" "$first" It prints "one two three four", instead of "one". This works on bash and Solaris sh, but not in dash. Oddly, not putting the white space between single quotes works: string="one two three four" first="${string%% *}" printf "%s\n" "$first" # Prints "one" To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/dash/+bug/1833817/+subscriptions -- Mailing list: https://launchpad.net/~touch-packages Post to : touch-packages@lists.launchpad.net Unsubscribe : https://launchpad.net/~touch-packages More help : https://help.launchpad.net/ListHelp