Package: timewarrior
Version: 1.4.3+ds.1-2
Severity: normal

Dear fellow Debian Developer,

bash completion is broken for tags with a description:

```console
$ mv ~/.timewarrior ~/.timewarrior.private
$ timew start foo
Create new database in ~/.timewarrior? (yes/no) yes
...
$ timew start bar
...
$ timew config tags.foo.description "some description"
Are you sure you want to add 'tags.foo.description' with a value of 'some 
description'? (yes/no) yes
Config file ~/.timewarrior/timewarrior.cfg modified.
$ timew tags | cat

Tag Description
--- ----------------
bar -
foo some description
    ^^^^^^^^^^^^^^^^

$ timew tag @1 <Tab><Tab>
bar                     foo\ some\ description
                           ^^^^^^^^^^^^^^^^^^^
```

This is caused by /usr/share/bash-completion/completions/timew:43-46
   43 function __get_tags()
   44 {
   45   timew tags | tail -n +4 -- | sed -e "s|[[:space:]]*-$||"
   46 }

which assumes that a line is always terminated by a dash, but that is
only true for tags having NO description. Sadly there doesn't seem to be
a command to only get the tag names.

```console
$ timew tag @1 SomeVeryLongTag\ with\ spaces
Note: '"SomeVeryLongTag with spaces"' is a new tag.
Added SomeVeryLongTag with spaces to @1
$ timew tags | cat

Tag                         Description
--------------------------- ----------------
SomeVeryLongTag with spaces -
bar                         -
foo                         some description

```

Maybe the following line can be used:
```
timew tags | nawk 'NR==3 {w=length($1)} NR>=4 {print 
gensub(/[[:space:]]+$/,"",1,substr($0,0,w))}'
```

Upstream already changed the code to looke like this:
```sh
function __get_tags()
{
  timew get dom.tracked.tags "${TIMEW_COMPLETION_TAGS_RANGE:-":all"}"
}
```
<https://github.com/GothenburgBitFactory/timewarrior/blob/develop/completion/timew-completion.bash#L45>
<https://github.com/GothenburgBitFactory/timewarrior/commit/9c49d4df2de121d1b68fef0f7b6be906ab962218>

But that code is broken for "tags with spaces" as spaces are also used
to seperate multiple tags from each other:
```console
$ timew get dom.tracked.tags :all | xxd
00000000: 536f 6d65 5665 7279 4c6f 6e67 5461 6720  SomeVeryLongTag
                                               ^^
00000010: 7769 7468 2073 7061 6365 7320 6261 7220  with spaces bar
                    ^^                         ^^
00000020: 666f 6f0a                                foo.
```

Philipp
-- System Information:
Debian Release: 12.7
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable-security'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 6.10.6+bpo-amd64 (SMP w/12 CPU threads; PREEMPT)
Kernel taint flags: TAINT_OOT_MODULE
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages timewarrior depends on:
ii  libc6       2.36-9+deb12u8
ii  libgcc-s1   12.2.0-14
ii  libstdc++6  12.2.0-14

Versions of packages timewarrior recommends:
ii  taskwarrior  2.6.2+dfsg-1

Versions of packages timewarrior suggests:
ii  python3  3.11.2-1+b1

-- no debconf information

Reply via email to