kojiromike / parameter-expansion

POSIX Parameter Expansion in Python
Apache License 2.0
5 stars 1 forks source link

Unexpected behavior with ":-" when expansion has spaces #39

Open ach5948 opened 1 month ago

ach5948 commented 1 month ago

This is may be a bashism, but parameter_expansion seems to differ from bash when the replacement value for :- has spaces in it.

Description

Example:

bash:

$ echo "-${FOO:-testing string}-"
-testing string-

parameter-expansion:

>>> parameter_expansion.expand("-${FOO:-testing string}-")
'-testing-'

(Expected: `'-testing value-')

Additionally, and possibly related, adding single quotes also differs from bash:

bash:

$ echo "-${FOO:-'testing string'}-"
-'testing string'-

parameter-expansion:

>>> parameter_expansion.expand("-${FOO:-'testing string'}-")
'-testing string-'

(Expected: "-'testing string'-")

Affected Versions

This issue appears for python 3.10 on the main branch, and for python 3.8 for parameter-expansion 0.2.0 and parameter-expansion-patched 0.3.1 (no other python/package combinations were tried)