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 Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/1833817 Title: Substring expansion "${string%%' '*}" doesn't work To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/dash/+bug/1833817/+subscriptions -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs