Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix completion log saving in current directory when program name contains certain characters #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions etc/dashdash.bash_completion.in
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,16 @@


# Debugging this completion:
# 1. Uncomment the "_{{name}}_log_file=..." line.
# 1. Uncomment the "_log_file=..." line.
# 2. 'tail -f /var/tmp/dashdash-completion.log' in one terminal.
# 3. Re-source this bash completion file.
#_{{name}}_log=/var/tmp/dashdash-completion.log

function _{{name}}_completion_logfile {
local _log_file=/dev/null
#_log_file=/var/tmp/dashdash-completion.log
echo $_log_file
}


function _{{name}}_completer {

Expand Down Expand Up @@ -335,24 +341,20 @@ function _{{name}}_completer {
# adapted from 'npm completion'.
if type complete &>/dev/null; then
function _{{name}}_completion {
local _log_file=/dev/null
[[ -z "$_{{name}}_log" ]] || _log_file="$_{{name}}_log"
COMPREPLY=($(COMP_CWORD="$COMP_CWORD" \
COMP_LINE="$COMP_LINE" \
COMP_POINT="$COMP_POINT" \
_{{name}}_completer -- "${COMP_WORDS[@]}" \
2>$_log_file)) || return $?
2>$(_{{name}}_completion_logfile))) || return $?
}
complete -o default -F _{{name}}_completion {{name}}
elif type compdef &>/dev/null; then
function _{{name}}_completion {
local _log_file=/dev/null
[[ -z "$_{{name}}_log" ]] || _log_file="$_{{name}}_log"
compadd -- $(COMP_CWORD=$((CURRENT-1)) \
COMP_LINE=$BUFFER \
COMP_POINT=0 \
_{{name}}_completer -- "${words[@]}" \
2>$_log_file)
2>$(_{{name}}_completion_logfile))
}
compdef _{{name}}_completion {{name}}
elif type compctl &>/dev/null; then
Expand All @@ -363,13 +365,11 @@ elif type compctl &>/dev/null; then
let cword-=1
read -l line
read -ln point
local _log_file=/dev/null
[[ -z "$_{{name}}_log" ]] || _log_file="$_{{name}}_log"
reply=($(COMP_CWORD="$cword" \
COMP_LINE="$line" \
COMP_POINT="$point" \
_{{name}}_completer -- "${words[@]}" \
2>$_log_file)) || return $?
2>$(_{{name}}_completion_logfile))) || return $?
}
compctl -K _{{name}}_completion {{name}}
fi
Expand Down