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

todo.txt inode changing - using symlinked or hardlinked todo.txt not possible #272

Open
jonniestuefer opened this issue Mar 10, 2019 · 2 comments

Comments

@jonniestuefer
Copy link

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

What is the current behavior?
If I symlink or hardlink a file to ~/.todo-txt/todo.txt and then use todotxt-cli to modify it, the inode of the file changes (when hardlinked) or the symlinked file is replaced by a new file.

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 list file, e.g. touch ~/.todo-txt/test.txt
  2. Link it to todo.txt (ln -s ~/.todo-txt/test.txt ~/.todo-txt/todo.txt)
  3. Add an entry (todotxt add "a new entry")
  4. Check if todo.txt is still symlinked to test.txt
    or
  5. Create a todo list file, e.g. touch ~/.todo-txt/test.txt
  6. Link it to todo.txt (ln ~/.todo-txt/test.txt ~/.todo-txt/todo.txt)
  7. Check inodes are the same (ls -i ~/.todo-txt/test.txt and ls -i ~/.todo-txt/todo.txt
  8. Add an entry (todotxt add "a new entry")
  9. Check inodes are the same (ls -i ~/.todo-txt/test.txt and ls -i ~/.todo-txt/todo.txt

What is the expected behavior?
I would expect the symlink or hardlink to remain

Which versions todo.sh are you using?

Run todo.sh -V
The command is todotxt-cli -V on my Ubuntu and it returns the following:

First release: 5/11/2006
Original conception by: Gina Trapani (http://ginatrapani.org)
Contributors: http://github.com/ginatrapani/todo.txt-cli/network
License: GPL, http://www.gnu.org/copyleft/gpl.html
More information and mailing list at http://todotxt.com
Code repository: http://github.com/ginatrapani/todo.txt-cli/tree/master

Which Operating System are you using?
Ubuntu 18.04.2 LTS

Which version of bash are you using?

Run bash --version
GNU bash, version 4.4.19(1)-release (x86_64-pc-linux-gnu)

@inkarkat
Copy link
Member

The (very useful) functionality to keep a backup copy (in todo.txt this is implemented via sed -i.bak) in case something goes wrong changes the inode number. I think many applications do this (e.g. Vim), and having a guarantee to maintain the inode is rare.

Now for symbolic links, I think todo.txt would have to resolve the link target (readlink -nf) to avoid breaking it. This could be implemented, but it raises compatibility issues (what if there's no readlink installed?)

What many people do (and what works very well) is linking the todo.txt directory instead of individual files. As there's a close connection between files (e.g. archived tasks go into done.txt), I think this setup also makes a lot more sense. Wouldn't this approach work for you, too?!

@jonniestuefer
Copy link
Author

Thanks for the quick response.

I wasn't aware that this is expected behaviour. So basically, you rename the todo.txt file to todo.txt.bak and create a new todo.txt file.

Linking the directory would be a possibility, which I will try out. I just would have preferred linking the individual files, since I've other stuff in there too.

I find the way it works counter-intuitive, but maybe I'm alone there.

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

No branches or pull requests

2 participants