Skip to content

expand: parameter expansions with spaces in the middle of words are mishandled #886

@dkegel-fastly

Description

@dkegel-fastly

It feels like gosh trims leading and trailing spaces from variables:

$ cat x.sh
#!/bin/sh
FOO=" Q "
echo a${FOO}b
export FOO
env | grep FOO | sed 's/$/$/'
$ sh x.sh
a Q b
FOO= Q $
$ go run main.go x.sh
aQb
FOO= Q $

I would have expected gosh x.sh and sh x.sh to produce identical output, but gosh outputs "aQb" while sh outputs "a Q b".

Looks like the variable has the spaces, but they are trimmed during variable expansion?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions