diff --git a/nb b/nb index 3466faf94..242a66936 100755 --- a/nb +++ b/nb @@ -1240,7 +1240,8 @@ Can't edit archives. Export archive and expand to edit.\\n" touch "${_file_path:-}" fi - eval "${_editor_command} \"${_file_path}\"" + escaped=${_file_path//$/\\$} + eval "${_editor_command} \"$escaped\"" fi } @@ -5719,7 +5720,8 @@ _index() { # grep -n "^${1:-}$" "${2:-}" | cut -f1 -d: # awk 'match($0,v){print NR; exit}' v="^${1:-}$" "${2:-}" # rg --color=never --line-number "^${1:-}$" "${2:-}" | cut -d: -f1 - sed -n "/^${1:-}$/=" "${2:-}" + escaped=$(printf "%s" "${1:-}" | sed -e 's/[\[\*]/\\&/g') + sed -n "/^$escaped$/=" "${2:-}" } local _basename="${2:-}" @@ -6427,7 +6429,8 @@ HEREDOC local _item_identifier= # use `sed` directly instead of `_index get_id` for performance _item_identifier="$( - sed -n "/^${__basename:-}$/=" "${_notebook_path:-}/.index" + escaped=$(printf "%s" "${__basename:-}" | sed -e 's/[\[\*]/\\&/g') + sed -n "/^$escaped$/=" "${_notebook_path:-}/.index" )" local _max_identifier="${_max_id}"