Fix atuin crashing on commands that start with -- (#509)

The use of `--` in the shell scripts prevents clap attempting to parse
the command name as a flag, in the case that it starts with `--`.
This commit is contained in:
Jamie Quigley 2022-08-23 17:26:42 +01:00 committed by GitHub
parent 225c41493e
commit aa556fa088
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 9 deletions

View File

@ -2,7 +2,7 @@ ATUIN_SESSION=$(atuin uuid)
export ATUIN_SESSION export ATUIN_SESSION
_atuin_preexec() { _atuin_preexec() {
local id; id=$(atuin history start "$1") local id; id=$(atuin history start -- "$1")
export ATUIN_HISTORY_ID="${id}" export ATUIN_HISTORY_ID="${id}"
} }
@ -11,13 +11,13 @@ _atuin_precmd() {
[[ -z "${ATUIN_HISTORY_ID}" ]] && return [[ -z "${ATUIN_HISTORY_ID}" ]] && return
(RUST_LOG=error atuin history end "${ATUIN_HISTORY_ID}" --exit "${EXIT}" &) > /dev/null 2>&1 (RUST_LOG=error atuin history end --exit "${EXIT}" -- "${ATUIN_HISTORY_ID}" &) > /dev/null 2>&1
} }
__atuin_history () __atuin_history ()
{ {
tput rmkx tput rmkx
HISTORY="$(RUST_LOG=error atuin search -i "${READLINE_LINE}" 3>&1 1>&2 2>&3)" HISTORY="$(RUST_LOG=error atuin search -i -- "${READLINE_LINE}" 3>&1 1>&2 2>&3)"
tput smkx tput smkx
READLINE_LINE=${HISTORY} READLINE_LINE=${HISTORY}

View File

@ -1,19 +1,19 @@
set -gx ATUIN_SESSION (atuin uuid) set -gx ATUIN_SESSION (atuin uuid)
function _atuin_preexec --on-event fish_preexec function _atuin_preexec --on-event fish_preexec
set -gx ATUIN_HISTORY_ID (atuin history start "$argv[1]") set -gx ATUIN_HISTORY_ID (atuin history start -- "$argv[1]")
end end
function _atuin_postexec --on-event fish_postexec function _atuin_postexec --on-event fish_postexec
set s $status set s $status
if test -n "$ATUIN_HISTORY_ID" if test -n "$ATUIN_HISTORY_ID"
RUST_LOG=error atuin history end $ATUIN_HISTORY_ID --exit $s & RUST_LOG=error atuin history end --exit $s -- $ATUIN_HISTORY_ID &
disown disown
end end
end end
function _atuin_search function _atuin_search
set h (RUST_LOG=error atuin search -i (commandline -b) 3>&1 1>&2 2>&3) set h (RUST_LOG=error atuin search -i -- (commandline -b) 3>&1 1>&2 2>&3)
commandline -f repaint commandline -f repaint
if test -n "$h" if test -n "$h"
commandline -r $h commandline -r $h

View File

@ -13,7 +13,7 @@ export ATUIN_SESSION=$(atuin uuid)
export ATUIN_HISTORY="atuin history list" export ATUIN_HISTORY="atuin history list"
_atuin_preexec(){ _atuin_preexec(){
local id; id=$(atuin history start "$1") local id; id=$(atuin history start -- "$1")
export ATUIN_HISTORY_ID="$id" export ATUIN_HISTORY_ID="$id"
} }
@ -23,7 +23,7 @@ _atuin_precmd(){
[[ -z "${ATUIN_HISTORY_ID}" ]] && return [[ -z "${ATUIN_HISTORY_ID}" ]] && return
(RUST_LOG=error atuin history end $ATUIN_HISTORY_ID --exit $EXIT &) > /dev/null 2>&1 (RUST_LOG=error atuin history end --exit $EXIT -- $ATUIN_HISTORY_ID &) > /dev/null 2>&1
} }
_atuin_search(){ _atuin_search(){
@ -34,7 +34,7 @@ _atuin_search(){
echoti rmkx echoti rmkx
# swap stderr and stdout, so that the tui stuff works # swap stderr and stdout, so that the tui stuff works
# TODO: not this # TODO: not this
output=$(RUST_LOG=error atuin search -i $BUFFER 3>&1 1>&2 2>&3) output=$(RUST_LOG=error atuin search -i -- $BUFFER 3>&1 1>&2 2>&3)
echoti smkx echoti smkx
if [[ -n $output ]] ; then if [[ -n $output ]] ; then