Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Append tool overwrites beginning of todo line #258

Open
kdonavin opened this issue Aug 17, 2018 · 11 comments
Open

Append tool overwrites beginning of todo line #258

kdonavin opened this issue Aug 17, 2018 · 11 comments

Comments

@kdonavin
Copy link

Do you want to request a feature or report a bug?

Reporting a bug

What is the current behavior?

If I append to an "old" line (a todo.txt line created perhaps 24 hours or more prior), the beginning of the line is overwritten with the appended text, instead of appending to the end of the line. The append tool works as expected if I recently added the line to todo.txt

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.

  1. Create a todo.txt line, wait a couple days OR find an old line
  2. todo.sh append Test to the line

See the following for erroneous example:

bad_append

again_bad_append

What is the expected behavior?

In contrast to the normal functioning:

  1. Create a new todo.txt line
  2. todo.sh append to that line.

See this correct example:

good_append

Which versions todo.sh are you using?

Run todo.sh -V

TODO.TXT Command Line Interface v2.11.0

Which Operating System are you using?

MacOS 10.13.6

Which version of bash are you using?

Run bash --version

GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin17)

@karbassi
Copy link
Member

@kdonavin Thanks for the bug report. 👍

Can you paste your config file? Can you also paste your todo.txt file?

The way the append command should work is to add text to the end of the task. For some reason, yours is putting in the beginning. You've noticed this correctly. I'm wondering why older tasks have this problem, but not newer ones.

I couldn't replicate this on my test, so let's see what's different.

Trying to replicate
$ ./todo.sh -d todo.cfg ls
--
TODO: 0 of 0 tasks shown

$ ./todo.sh -d todo.cfg add "Investigate solo backpacking trip or consider saving PTO +NorthVaca"
1 Investigate solo backpacking trip or consider saving PTO +NorthVaca
TODO: 1 added.

$ ./todo.sh -d todo.cfg append 1 +GoNorth
1 Investigate solo backpacking trip or consider saving PTO +NorthVaca +GoNorth

@kdonavin
Copy link
Author

I am happy to post my config file, although I'd rather not post my entire todo.txt file because I don't recall whether or not I have personal information in there. But, I can add that it appears in my todo.txt file that the append is actually creating a new line in todo.txt that is printed and interpreted as one line in todo.sh, similar to a carriage return.

Shell

shell

Text Editor

text_editor

config:

# === EDIT FILE LOCATIONS BELOW ===

# Your todo.txt directory (this should be an absolute path)
export TODO_DIR="/Users/kirkwooddonavin/Dropbox/todo-txt"

# Your todo/done/report.txt locations
export TODO_FILE="$TODO_DIR/todo.txt"
export DONE_FILE="$TODO_DIR/done.txt"
export REPORT_FILE="$TODO_DIR/report.txt"

# You can customize your actions directory location
#export TODO_ACTIONS_DIR="$HOME/.todo.actions.d"

# == EDIT FILE LOCATIONS ABOVE ===

# === COLOR MAP ===

## Text coloring and formatting is done by inserting ANSI escape codes.
## If you have re-mapped your color codes, or use the todo.txt
## output in another output system (like Conky), you may need to
## over-ride by uncommenting and editing these defaults.
## If you change any of these here, you also need to uncomment
## the defaults in the COLORS section below. Otherwise, todo.txt
## will still use the defaults!

# export BLACK='\\033[0;30m'
# export RED='\\033[0;31m'
# export GREEN='\\033[0;32m'
# export BROWN='\\033[0;33m'
# export BLUE='\\033[0;34m'
# export PURPLE='\\033[0;35m'
# export CYAN='\\033[0;36m'
# export LIGHT_GREY='\\033[0;37m'
# export DARK_GREY='\\033[1;30m'
# export LIGHT_RED='\\033[1;31m'
# export LIGHT_GREEN='\\033[1;32m'
# export YELLOW='\\033[1;33m'
# export LIGHT_BLUE='\\033[1;34m'
# export LIGHT_PURPLE='\\033[1;35m'
# export LIGHT_CYAN='\\033[1;36m'
# export WHITE='\\033[1;37m'
# export DEFAULT='\\033[0m'

# === COLORS ===

## Uncomment and edit to override these defaults.
## Reference the constants from the color map above,
## or use $NONE to disable highlighting.
#
# Priorities can be any upper-case letter.
# A,B,C are highlighted; you can add coloring for more.
#
# export PRI_A=$YELLOW        # color for A priority
# export PRI_B=$GREEN         # color for B priority
# export PRI_C=$LIGHT_BLUE    # color for C priority
# export PRI_D=...            # define your own
# export PRI_X=$WHITE         # color unless explicitly defined

# There is highlighting for tasks that have been done,
# but haven't been archived yet.
#
# export COLOR_DONE=$LIGHT_GREY

# There is highlighting for projects and contexts.
#
# export COLOR_PROJECT=$RED
# export COLOR_CONTEXT=$RED

# === BEHAVIOR ===

## customize list output
#
# TODOTXT_SORT_COMMAND will filter after line numbers are
# inserted, but before colorization, and before hiding of
# priority, context, and project.
#
# export TODOTXT_SORT_COMMAND='env LC_COLLATE=C sort -f -k2'

# TODOTXT_FINAL_FILTER will filter list output after colorization,
# priority hiding, context hiding, and project hiding. That is,
# just before the list output is displayed.
#
# export TODOTXT_FINAL_FILTER='cat'

Does that help? If not, I can create a test todo.txt file and try to reproduce that way.

@kdonavin
Copy link
Author

Accidentally clicked closed.

@kdonavin kdonavin reopened this Aug 20, 2018
@karbassi
Copy link
Member

@kdonavin can you post what td is aliased to?

alias td
which t

@kdonavin
Copy link
Author

kdonavin commented Aug 23, 2018

Sure, it is an alias for todo.sh:

alias td='todo.sh'

@michaelhagedon
Copy link

I also observe this behavior on Ubuntu 18.04.

@munkee
Copy link

munkee commented Nov 4, 2018

I'm unable to replicate this on a very similar setup. Can you patch your todo.sh to include debugging info and send back the output of an incorrect append?

download this patch https://gist.github.com/munkee/7c27d074f1a34863b8b664feb1b835df
and patch like this $ patch -p0 < todo_issue_258.patch

@kdonavin
Copy link
Author

I apologize for the delay. This is the message I get after applying your patch.

[.../bin]>> td append 490 and hours today
+ errmsg='usage: todo.sh append ITEM# "TEXT TO APPEND"'
+ shift
+ item=490
+ shift
+ getTodo 490
+ local item=490
+ '[' -z 490 ']'
+ '[' '' ']'
++ sed '490!d' /Users/kirkwooddonavin/Dropbox/todo-txt/todo.txt
' todo='(A) Schedule WFH and Feb Vaca +Womply
' ']' -z '(A) Schedule WFH and Feb Vaca +Womply
+ [[ -z and ]]
+ input='and hours today'
+ case "$input" in
+ appendspace=' '
+ cleaninput 'for sed'
+ input='and hours today'
+ input='and hours today'
+ '[' 'for sed' = 'for sed' ']'
+ input='and hours today'
+ input='and hours today'
+ input='and hours today'
+ sed -i.bak '490 s|^.*|& and hours today|' /Users/kirkwooddonavin/Dropbox/todo-txt/todo.txt
+ '[' 1 -gt 0 ']'
+ getNewtodo 490
+ local item=490
+ '[' -z 490 ']'
+ '[' '' ']'
++ sed '490!d' /Users/kirkwooddonavin/Dropbox/todo-txt/todo.txt
 and hours today'hedule WFH and Feb Vaca +Womply
 and hours today' ']'e WFH and Feb Vaca +Womply
 and hours today'chedule WFH and Feb Vaca +Womply
 and hours today WFH and Feb Vaca +Womply
+ set +x

I got this warning when I patched too:
screen shot 2019-01-15 at 8 41 59 am

The problem persists. Before:
screen shot 2019-01-15 at 8 57 43 am

After:
screen shot 2019-01-15 at 8 57 34 am

Does that help, @munkee

@munkee
Copy link

munkee commented Jan 16, 2019

Still can't tell exactly what's causing it to mess up, I can see that everything is going correctly and the same as here until the last 5 lines there. Can you try your commands with TODOTXT_VERBOSE=0. Like this
>> TODOTXT_VERBOSE=0 td append 490 and hours today and see if perhaps the verbose output (the last few lines) is what is messing up the file.

Also what version of Dropbox is running on the Mac to synchronize it. Is there any other programs that might be automatically doing anything with your todo.txt file out from under the program?

@kdonavin
Copy link
Author

kdonavin commented May 8, 2019

@munkee I am not aware of any other programs that are altering these files, no.

Dropbox version v72.4.136 -- the most current version from Home Brew repos.

Thanks for the TODOTXT_VERBOSE=0 tip. Alas, it did not work, despite successfully halting the verbose printout:

Screen Shot 2019-05-08 at 1 59 32 PM

@the1ts
Copy link
Contributor

the1ts commented Jul 4, 2021

I know this is quite old now, but I have one question, does this only look this way when viewed with todo.sh? i.e. when you edit the actual todo.txt file does the append still look to have failed?
I ask as the final sed line looks to have some bash escape code magic going on moving the cursor during the echo of the appended line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants