mirror of
https://github.com/junegunn/fzf.git
synced 2026-08-01 21:50:28 +08:00
Skip FZF_CURRENT_ITEM export when item contains NUL
- exec(2) rejects env entries containing NUL, breaking preview and other child commands when the input has NUL bytes - skip the export and document the limitation Fix #2395
This commit is contained in:
+4
-1
@@ -1439,7 +1439,10 @@ func (t *Terminal) environImpl(forPreview bool) []string {
|
||||
env = append(env, fmt.Sprintf("FZF_COLUMNS=%d", t.areaColumns))
|
||||
env = append(env, fmt.Sprintf("FZF_POS=%d", min(t.merger.Length(), t.cy+1)))
|
||||
if item := t.currentItem(); item != nil {
|
||||
env = append(env, "FZF_CURRENT_ITEM="+item.AsString(t.ansi))
|
||||
// Skip if the value contains a NUL byte; exec(2) would reject the env.
|
||||
if s := item.AsString(t.ansi); !strings.ContainsRune(s, 0) {
|
||||
env = append(env, "FZF_CURRENT_ITEM="+s)
|
||||
}
|
||||
}
|
||||
env = append(env, fmt.Sprintf("FZF_CLICK_HEADER_LINE=%d", t.clickHeaderLine))
|
||||
env = append(env, fmt.Sprintf("FZF_CLICK_HEADER_COLUMN=%d", t.clickHeaderColumn))
|
||||
|
||||
Reference in New Issue
Block a user