Substring expansion "${string%%' '*}" doesn't work
Bug #1833817 reported by
janlz
This bug affects 1 person
| Affects | Status | Importance | Assigned to | Milestone | |
|---|---|---|---|---|---|
| dash (Ubuntu) |
New
|
Undecided
|
Unassigned | ||
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"
| tags: | added: bionic |
| summary: |
- Parameter expansion "${string%%' '*}" doesn't work + Substring expansion "${string%%' '*}" doesn't work |
| description: | updated |
| description: | updated |
To post a comment you must log in.
