From 373ad9393ad94ab6e7f1ed44a5893f276db70d33 Mon Sep 17 00:00:00 2001 From: Giuseppe Rota <403432+grota@users.noreply.github.com> Date: Wed, 26 Nov 2025 12:24:40 +0100 Subject: [PATCH] fix: bash widget sanitization for & In the bash widget readline code make sure that bash's `patsub_replacement` is temporarily unset to avoid having ${input}_NAVIEND in the final command when the expanded $replacement contains `&` --- shell/navi.plugin.bash | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/shell/navi.plugin.bash b/shell/navi.plugin.bash index 851b896..d63b106 100644 --- a/shell/navi.plugin.bash +++ b/shell/navi.plugin.bash @@ -16,8 +16,11 @@ _navi_widget() { local -r replacement="$(_navi_call --print --query "$last_command")" local output="$input" if [ -n "$replacement" ]; then - output="${input}_NAVIEND" - output="${output//$find/$replacement}" + output="${input}_NAVIEND" + output=$( + shopt -u patsub_replacement + printf '%s' "${output//"$find"/"$replacement"}" + ) fi fi @@ -33,4 +36,4 @@ if [ ${BASH_VERSION:0:1} -lt 4 ]; then bind '"\C-g": " \C-b\C-k \C-u`_navi_widget_legacy`\e\C-e\C-a\C-y\C-h\C-e\e \C-y\ey\C-x\C-x\C-f"' else bind -x '"\C-g": _navi_widget' -fi \ No newline at end of file +fi