todotxt / todo.txt-cli

☑️ A simple and extensible shell script for managing your todo.txt file.
http://todotxt.org
GNU General Public License v3.0
5.55k stars 712 forks source link

shell scripts in tests have the path #! /bin/bash hardwired #385

Open rudolfII opened 2 years ago

rudolfII commented 2 years ago

Perhaps sth like

!/usr/bin/env bash

would be better (once the todo.sh itself uses that)

Thanks Ruda

inkarkat commented 2 years ago

todo.sh itself uses that already; the motivation for that was

Now runs on OpenBSD without errors.

Apparently nobody uses OpenBSD for development :-) (I've used FreeBSD once to troubleshoot issues only found on MacOS.) Still should change it, if only for consistency.

rudolfII commented 2 years ago

I use OpenBSD; I can run todo.sh, but found that, eg, lsc, lsprj, ... do not work (they show nothing, though they should show something). Hence I tried to run the tests and found the fixed paths. I ran sed to replace those paths, ran the tests (I added '-' to the line 96: -cd tests && ./$(notdir $@) $(TEST_OPTIONS) to not stop at the first error) and found quite a few tests fail. The reason is (at least) due to the grep command, which differs between GNU and BSD, in particular:

GNU$ echo @home | grep -o "@[^ ]\\+"
@home
GNU$

while

BSD$ echo @home | grep -o "@[^ ]\\+"
BSD$

BSD does not recognize the \+ repetition. An easy way out could be, in this case BSD$ echo @home | grep -o "@[^ ][^ ]*" or use extended regexps with grep -E.

I will perhaps check all the grep calls and rewrite them for myself. (Though, todo.sh has started to seem too complex, so perhaps I will switch to sth. simpler, yet, based on PLAN9.) It still might be of some value to mention requirements somewhere on the project's page. It may, as happened to me, seem that todo.sh is 'just a simple shell script' that might easily run anywhere (with bash, unfortunately), but you actually need GNU grep, and maybe more.

Best regards and thanks, Ruda

inkarkat commented 2 years ago

Yeah, you've summarized the state of the code pretty well. Most users use the GNU toolchain (Linux, and Windows with Cygwin); MacOS has always been the problematic one with regards to compatibility, but the BSD family has never been in the focus so far; you might be the first one that attempts to use it there!

I'd certainly welcome a pull request that changes grep to extended regular expressions, if that (plus the use of env bash) already makes todo.sh usable on OpenBSD. Another problem might be with AWK, though. And if you plan to use any add-ons, these probably are even worse (mine included).