Closed randy closed 2 years ago
You'll want to escape those backticks because your shell is going to see those and try to execute that as a shell command before adding that to your todo.
craig@kryten:~$ t add Test `date +%F` @computer
172 Test 2021-11-16 @computer
TODO: 172 added.
You'll want to do the following to add the back ticks explicitly:
craig@kryten:~$ t add Test \`date +%F\` @computer
173 Test `date +%F` @computer
TODO: 173 added.
Alternatively, you can add the task interactively:
craig@kryten:~$ t add
Add: Test `date +%F` @computer
175 Test `date +%F` @computer
TODO: 175 added.
Hope this helps!
It does help... I was just going to edit the issue to say it doesn't matter if these are contained in a fully-quoted string or not. I was having issues with single-quotes, too and fully-enclosing the todo in double-quotes fixed that, but not this.
I've gotten in the habit of escaping single quotes as well:
craig@lister:~$ t add This isn\'t an issue when you escape the single quotes @computer
173 This isn't an issue when you escape the single quotes @computer
TODO: 173 added.
It takes practice, but eventually it'll become second nature (or is that it\'ll. ;))
But yeah, even with double quotes bash will try to execute anything in the back-ticks.
As a programmer, you really should familiarize yourself with your shell's quoting rules :-) Craig already mentioned the rules (in Bash, either escape backticks with a prepended backslash, or enclose the whole text in single quotes (but then contained single quotes become a bit problematic)), or alternatively let the application query you for the task text.
This is not a bug; I use the backticks all the time to get command output into the task (e.g. todo.sh add clean up disk space @`hostname` soon
).
As a programmer, I often use back-ticks to denote code, so as I was blasting in my current todo-list, I wasn't even considering that this app would not handle back-ticks correctly. After all, it's just text! Sadly, I have quite a few todo items that make no sense because they're lacking the text contained within the back-ticks.
Do you want to request a feature or report a bug? Bug
What is the current behavior? When you add a task with back-ticks (`), the back-ticks and text inside is removed from the string.
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Enter the following in a terminal:
What is the expected behavior?
Which versions todo.sh are you using?
Which Operating System are you using? Mac OSX 10.15.7
Which version of bash are you using?