taskwarrior
taskwarrior copied to clipboard
Search for tasks with descriptions containing a hyphen
To report a bug...
- What command(s) did you run?
task add foo-bar
task foo-bar
- What did you expect to happen?
- The first command adds a new task with description "foo-bar" (this happens).
- The second command finds this added task and displays it.
- What actually happened?
$ task add foo-bar
Created task 303.
$ task list | grep foo-bar
303 1s foo-bar
$ task foo-bar
[task next ( foo-bar )]
Cannot subtract strings
- Paste the output of the
task diag
command.
$ task diag
task 2.5.1
Platform: Linux
Compiler
Version: 7.2.0
Caps: +stdc +stdc_hosted +LP64 +c8 +i32 +l64 +vp64 +time_t64
Compliance: C++11
Build Features
CMake: 3.9.5
libuuid: libuuid + uuid_unparse_lower
libgnutls: 3.5.16
Build type: None
Configuration
File: /home/user/.taskrc (found), 2894 bytes, mode 100644
Data: /home/user/.task (found), dir, mode 40755
Locking: Enabled
GC: Enabled
$EDITOR: vim
Server: servername:53589
CA: /home/user/.task/ca.cert.pem, readable, XXX bytes
Trust: strict
Certificate: /home/user/.task/client.cert.pem, readable, YYY bytes
Key: /home/user/.task/client.key.pem, readable, ZZZ bytes
Ciphers: NORMAL
Creds: AAA/user/************************************
Hooks
System: Enabled
Location: /home/user/.task/hooks
Active: [...]
Tests
$TERM: xterm-256color (276x56)
Dups: Scanned NNN tasks for duplicate UUIDs:
Found duplicate [...]
Broken ref: Scanned NNN tasks for broken references:
No broken references found
Note that there were several issues related to hyphens:
#1307 (about adding tasks including hyphens, which seems to work now) #289 (about numbers in combination with hyphens) #1657 (a similar issue as the one I am reporting here, but for project names instead; according to my tests this seems to be resolved)
The term foo-bar
looks like an expression. Use task /foo-bar/
.
I guess you mean an expression in the sense of https://taskwarrior.org/docs/terminology.html#expression. What exactly is treated as an expression? The documentation does not mention the hyphen. It says
An algebraic expression is a mathematical expression comprised of constants, operators and symbols.
What are the valid constants, operators and symbols?
Any r-value is treated as a possible expression, if it contains operators.
How do I prevent this interpretation of arbitrary tags as expressions?
# task +foo-bar list
Cannot subtract from a Boolean value
I tried all kinds of magic, like task +foo\\-bar list
and task +foo\\\\-bar list
(output the same error) and task +'"Freiheit-Ulmo-Iteration102"' list
(lists not the stories I would expect), but nothing works.
Filtering for descriptions containing a hyphen is now supported on 2.6.0.
To be exact, the following syntax needs to be used:
task desc:one-two
I noticed that searching for a task also fails when enumarting with a comma without space between.
$ task exec
$ task exec,
[task next ( exec, )]
ID Age Tag Description Urg
42 3h bash when and how to use exec, xargs, tee, sh -c, bash groups, subshells and process substitution 0.8
1 task
@heiderich This is not a failed search, but in fact a very accidental use of task execute
command:
task execute <external command>
Executes the specified command. Not useful by itself, but
when used in conjunction with aliases and extensions can
provide seamless integration.
Perhaps task
should error out instead of being silent when execute
is ran with no parameters. I'll spin it out into a separate issue.
The task one-two
search still fails, or rather, matches all the tasks.
The desc:one-two
or /one-two/
filters work as expected and can be used as a workaround. Keeping this open until all cases are resolved.
Just an additional case:
A forward slash in the search term seems unsearchable, which makes searching for URLs impossible.
task add visit example.com/foo/bar
task example.com/foo/bar
shows all tasks
task desc:example.com/foo/bar
shows No matches
task desc:example.com\/foo\/bar
shows No matches
Tried various other escapings, and all either list all tasks or nothing.
v2.6.1
Update for anyone else finding this:
After going through the source and the debug output (add rc.debug.parser:3
to the command line), it became clear that the lexer spots a url
and also a path
(which is something that seems to have more than one /
in it), but then doesn't make that a description
filter - that's only done for a plain string.
The desc:
also only works for plain strings, and regexes with paths separators don't work.
But there is a workaround that works :tada:
task "desc~https://example.com/foo/bar/baz"
Note that this is a regex search, so needs to be treated as such.
Now I wonder why can't TaskWarrior do just a plain string search by default?