${var:+FOO} mishandles empty vars
- Ngôn ngữ chính
- Go
- Star
- 907
- Fork
- 96
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
```console
$ export empty=''
$ echo '[${empty:+FOO}]' | envsubst
[FOO]
```
This is not what shell does:
```console
$ echo "[${empty:+FOO}]"
[]
```
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Hướng nghiên cứu
Look at the parsing and substitution logic in the Go source code, likely in a file like `envsubst.go` or `parser.go`. The issue demonstrates that the `${var:+FOO}` syntax incorrectly substitutes when the variable is set but empty. Compare the shell's behavior (Bash) to the current implementation. Write a test to reproduce the bug, then modify the substitution logic to handle empty strings correctly. Check for similar patterns like `${var:-FOO}` to ensure consistency.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- go, shell
- Lĩnh vực
- cli, tooling
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 55/100