Fixes issue where bash paths were not correctly deconstructed, leading to unit tests failing when the path had a space in it

This commit is contained in:
Nate Wheeler 2021-01-27 08:37:39 -06:00 committed by Tomas Babej
parent 5f39b368b6
commit 9be55fc070
3 changed files with 16 additions and 12 deletions

View file

@ -50,14 +50,16 @@
#
################################################################################
#the following variable is substituted for by ../../test/bash_completion.t
taskcommand='task rc.verbose:nothing rc.confirmation:no rc.hooks:off'
taskbin='task'
taskrc=''
taskcommand="rc.verbose:nothing rc.confirmation:no rc.hooks:off ${taskrc}"
_task_get_tags() {
$taskcommand _tags
"$taskbin" $taskcommand _tags
}
_task_get_config() {
$taskcommand _config
"$taskbin" $taskcommand _config
}
_task_offer_priorities() {
@ -65,14 +67,14 @@ _task_offer_priorities() {
}
_task_offer_projects() {
COMPREPLY=( $(compgen -W "$($taskcommand _projects)" -- ${cur/*:/}) )
COMPREPLY=( $(compgen -W "$("$taskbin" $taskcommand _projects)" -- ${cur/*:/}) )
}
_task_offer_contexts() {
COMPREPLY=( $(compgen -W "$($taskcommand _context) define delete list none show" -- $cur) )
COMPREPLY=( $(compgen -W "$("$taskbin" $taskcommand _context) define delete list none show" -- $cur) )
}
_task_context_alias=$($taskcommand show | grep 'alias.*context' | cut -d' ' -f1 | cut -d. -f2)
_task_context_alias=$("$taskbin" $taskcommand show | grep 'alias.*context' | cut -d' ' -f1 | cut -d. -f2)
_task()
{
@ -92,9 +94,9 @@ _task()
# echo "prev='$prev'"
# echo "prev2='$prev2'"
abbrev_min=$($taskcommand show | grep "abbreviation.minimum" | awk {'print $2'})
commands_aliases=$(echo $($taskcommand _commands; $taskcommand _aliases) | tr " " "\n"|sort|tr "\n" " ")
opts="$commands_aliases $($taskcommand _columns)"
abbrev_min=$("$taskbin" $taskcommand show | grep "abbreviation.minimum" | awk {'print $2'})
commands_aliases=$(echo $("$taskbin" $taskcommand _commands; "$taskbin" $taskcommand _aliases) | tr " " "\n"|sort|tr "\n" " ")
opts="$commands_aliases $("$taskbin" $taskcommand _columns)"
case "${prev}" in
$_task_context_alias|cont|conte|contex|context)

View file

@ -60,8 +60,10 @@ def prepare_tasksh(t):
for line in fh:
line = line.rstrip()
if line == "taskcommand='task rc.verbose:nothing rc.confirmation:no rc.hooks:off'":
line = "taskcommand='{0} rc.verbose:nothing rc.confirmation:no rc.hooks:off rc:{1}'".format(t.taskw, t.taskrc)
if line == "taskbin='task'":
line = "taskbin='{0}'".format(t.taskw)
if line == "taskrc=''":
line = "taskrc='rc:{0}'".format(t.taskrc)
tasksh.append(line)

View file

@ -35,7 +35,7 @@ function find_task_binary {
for t in "${bashtap_org_pwd}/task" "${bashtap_org_pwd}/src/task" "${bashtap_org_pwd}/../task" "${bashtap_org_pwd}/../src/task" "${bashtap_org_pwd}/../build/src/task"; do
if [ -f "$t" ] && [ -x "$t" ]; then
t_abs=$(bashtap_get_absolute_path "$t")
eval "function task { ${t_abs} rc:taskrc \"\$@\"; }"
eval "function task { '${t_abs}' rc:taskrc \"\$@\"; }"
return 0
fi
done