mirror of
https://github.com/junegunn/fzf
synced 2026-06-09 10:03:17 +00: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:
@@ -1531,6 +1531,10 @@ fzf exports the following environment variables to its child processes.
|
||||
.br
|
||||
.BR FZF_RAW " Only in raw mode. 1 if the current item matches, 0 otherwise"
|
||||
|
||||
.PP
|
||||
.B FZF_CURRENT_ITEM
|
||||
is omitted when the item contains a NUL byte, because exec(2) cannot pass it.
|
||||
|
||||
.SH EXTENDED SEARCH MODE
|
||||
|
||||
Unless specified otherwise, fzf will start in "extended\-search mode". In this
|
||||
|
||||
+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