89luca89 / 89luca89/distrobox

[Error] Wrong handling of exported bash functions

未關閉
#2,008 2 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視
bug
主要語言
Go
星號
13k
分支
541
平均合併
20 小時 47 分鐘
30 天內合併 PR
4

描述

Please, before opening a bug:

- [x] make sure you've read the documentation.
- [x] Ensure there isn't already an open issue about this.
- [x] Ensure there isn't already a closed/resolved issue about this.

**Describe the bug**
An exported bash function appears as an environment variable with multiline value. It's incorrectly handled by distrobox, when building "--env" arguments for podman.

**To Reproduce**
- either
- Use openSUSE Tumbleweed as a host OS
- install mc
- or
- run in bash
```sh
mc()
{
. /usr/share/mc/mc-wrapper.sh
}
export -f mc
```
- verify result
```python
$ python3
Python 3.13.11 (main, Dec 19 2025, 18:38:03) [GCC] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.environ["BASH_FUNC_mc%%"]
'() { . /usr/share/mc/mc-wrapper.sh\n}'
```
- ```
#notice missing '}' at the end
$ distrobox enter --dry-run example | grep BASH_FUNC_mc
--env=BASH_FUNC_mc%%=() { . /usr/share/mc/mc-wrapper.sh
- ```
$ distrobox enter example
/bin/sh: mc: line 1: syntax error: unexpected end of file from `{' command on line 0
/bin/sh: error importing function definition for `mc'
bash: mc: line 1: syntax error: unexpected end of file from `{' command on line 0
bash: error importing function definition for `mc'
```

**Expected behavior**
It should probably just reject the env variable.

**Logs**
I think it's not relevant here.

**Desktop (please complete the following information):**

- Are you using podman, docker or lilipod? podman
- Which version or podman? 5.7.1
- Which version of distrobox? 1.8.2.4
- Which host distribution? openSUSE Tumbleweed
- How did you install distrobox? from repo

貢獻指南

開啟貢獻指南

研究方向

查看 distrobox 如何為 podman 建立 '--env' 引數,相關程式碼可能位於處理環境變數匯出的 Go 程式碼中。這個 bug 是多行 bash 函式匯出(例如 BASH_FUNC_mc%%)會被截斷,缺少結尾的 '}'。先找到 'distrobox enter' 命令處理環境變數的位置。在本機重現問題並進行測試,然後修改程式碼,使其能正確處理多行值,或拒絕這類變數。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
bash, go, shell
領域
cli, tooling
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
冷清
描述清晰度
描述清楚
新手友好度
65/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。