diff --git a/ChangeLog b/ChangeLog index 7d3a4c577..c7d9e8e5c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -14,6 +14,8 @@ Features + Virtual tags. Bugs + + No more bash completion of, for example, 'projABC:', or of 'proj:' if + abbreviation.minimum is greater than 4. + Fixed bug #1059, where CmdEdit was running garbage collection. + Fixed bug #1065, where CmdShow issued messages in incorrect situations. + Fixed bug #1060, where an error was not thrown correctly. diff --git a/scripts/bash/task.sh b/scripts/bash/task.sh index 2341ea1a0..0dc5df04f 100644 --- a/scripts/bash/task.sh +++ b/scripts/bash/task.sh @@ -92,44 +92,57 @@ _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 _ids) $($taskcommand _columns)" case "${prev}" in :) case "${prev2}" in - dep*) - _task_offer_dependencies + dep|depe|depen|depend|depends) + if [ ${#prev2} -ge $abbrev_min ]; then + _task_offer_dependencies + fi return 0 ;; - pri*) - _task_offer_priorities + pri|prior|priori|priorit|priority) + if [ ${#prev2} -ge $abbrev_min ]; then + _task_offer_priorities + fi return 0 ;; - pro*) - _task_offer_projects + pro|proj|proje|projec|project) + if [ ${#prev2} -ge $abbrev_min ]; then + _task_offer_projects + fi return 0 ;; esac ;; *) case "${cur}" in - pro*:*) + pro:*|proj:*|proje:*|projec:*|project:*) _task_offer_projects return 0 ;; :) case "${prev}" in - dep*) - _task_offer_dependencies + dep|depe|depen|depend|depends) + if [ ${#prev} -ge $abbrev_min ]; then + _task_offer_dependencies + fi return 0 ;; - pri*) - _task_offer_priorities + pri|prior|priori|priorit|priority) + if [ ${#prev} -ge $abbrev_min ]; then + _task_offer_priorities + fi return 0 ;; - pro*) - _task_offer_projects + pro|proj|proje|projec|project) + if [ ${#prev} -ge $abbrev_min ]; then + _task_offer_projects + fi return 0 ;; esac diff --git a/test/bash_completion.t b/test/bash_completion.t index 9ed38d227..45d377c0d 100755 --- a/test/bash_completion.t +++ b/test/bash_completion.t @@ -28,13 +28,14 @@ use strict; use warnings; -use Test::More tests => 7; +use Test::More tests => 25; # Create the rc file. if (open my $fh, '>', 'bug.rc') { print $fh "data.location=.\n"; print $fh "alias.samplealias=long\n"; + print $fh "abbreviation.minimum=5\n"; close $fh; ok (-r 'bug.rc', 'Created bug.rc'); @@ -76,14 +77,57 @@ if (open my $target, '>', 'task.sh') } # aliases should be expanded -my $output = qx{bash ./task.sh task sampleali}; +my $output = qx{bash ./task.sh task sampleali 2>&1}; ok ($? == 0, 'Exit status check'); like ($output, qr/samplealias/, 'Aliases are expanded'); -$output = qx{bash ./task.sh task m}; +# commands should be expanded +$output = qx{bash ./task.sh task m 2>&1}; ok ($? == 0, 'Exit status check'); like ($output, qr/modify/, 'expansion of \'m\' includes \'modify\''); +# "project:" should be expanded correctly and dependent on abbreviation.minimum +qx{../src/task rc:bug.rc add testing project expansion project:todd 2>&1}; + +# note the spaces between "projABC", ":", and "to" for correct bash parsing +$output = qx{bash ./task.sh task projeABC : to 2>&1}; +ok ($? == 0, 'Exit status check'); +unlike ($output, qr/todd/, '\'projeABC:\' does not expand'); + +$output = qx{bash ./task.sh task proje : to 2>&1}; +ok ($? == 0, 'Exit status check'); +like ($output, qr/todd/, '\'proje:\' does expand'); + +$output = qx{bash ./task.sh task proj : to 2>&1}; +ok ($? == 0, 'Exit status check'); +unlike ($output, qr/todd/, '\'proj:\' does not expand if abbreviation.minimum is 5'); + +# "priority:" should be expanded correctly and dependent on abbreviation.minimum +$output = qx{bash ./task.sh task priorABC : 2>&1}; +ok ($? == 0, 'Exit status check'); +unlike ($output, qr/H/, '\'priorABC:\' does not expand'); + +$output = qx{bash ./task.sh task prior : 2>&1}; +ok ($? == 0, 'Exit status check'); +like ($output, qr/H/, '\'prior:\' does expand'); + +$output = qx{bash ./task.sh task prio : 2>&1}; +ok ($? == 0, 'Exit status check'); +unlike ($output, qr/H/, '\'prio:\' does not expand if abbreviation.minimum is 5'); + +# "depends:" should be expanded correctly and dependent on abbreviation.minimum +$output = qx{bash ./task.sh task depenABC : 2>&1}; +ok ($? == 0, 'Exit status check'); +unlike ($output, qr/1/, '\'depenABC:\' does not expand'); + +$output = qx{bash ./task.sh task depen : 2>&1}; +ok ($? == 0, 'Exit status check'); +like ($output, qr/1/, '\'depen:\' does expand'); + +$output = qx{bash ./task.sh task depe : 2>&1}; +ok ($? == 0, 'Exit status check'); +unlike ($output, qr/1/, '\'depe:\' does not expand if abbreviation.minimum is 5'); + # Cleanup. unlink qw(pending.data completed.data undo.data backlog.data synch.key bug.rc task.sh); ok (! -r 'pending.data' &&