-
Notifications
You must be signed in to change notification settings - Fork 716
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
Inline mode not supported by NetBSD's sed #168
Comments
Hello @exitnode ! What about introducing a ${SED} variable and replace all sed invocations with that? (If that sounds reasonable please let me know and I'll try to write a possible patch about that!) Thank you! |
You don't need that.
You can define a
This one emulates the
|
@inkarkat should we include this in the documentation somewhere? |
Hello Ingo,
Ingo Karkat writes:
You can define a `sed` function in the config file and `export` it; `todo.sh` and any add-ons launched by it will then use that one:
export originalSed=$(which sed)
sed()
{
# Assumption: The in-place option is passed as the first argument.
if [ "$1" = '-i.bak' ]; then
shift
# Assumption: Only a single file is processed, and it is passed as the
# last argument.
file=${!#}
tmpFile=/tmp/todo.sh-sed.$$
"$originalSed" "$@" > "$tmpFile" && mv "$tmpFile" "$file"
else
"$originalSed" "$@"
fi
}
export -f sed
This one emulates the `sed -i` without requiring `gsed`. If you have the latter, the override becomes even simpler:
sed()
{
# Use gsed because it understands the -i in-place option.
gsed "$@"
}
export -f sed
Mmh, while it will probably do the trick after the installation...
What about the tests? Should also an ad-hoc config file be hacked
as well similarly? Or isn't better to substitute `sed' with `@SED@'
and then adjust them accordingly in a Makefile target? (similarly to
what it is done via `@DEV_VERSION@')
Thank you!
|
@karbassi I think this is only the first or maybe second time this came up. BSD isn't a terribly common platform, and most users are quite knowledgeable (and quite used to dealing with these compatibility issues). I'd wait until we see another such question, and now this should be more discoverable through this issue. @iamleot Are you really using BSD as your sole platform and intend to do todo.sh dev work? I once used FreeBSD to verify the compatibility with Mac OS (don't have any Apple hardware, and Gina always tested on Mac) - fortunately, Mac OS has suitable |
Hello Ingo,
Ingo Karkat writes:
@iamleot Are you really using BSD as your sole platform and intend to do todo.sh dev work? I once used FreeBSD to verify the compatibility with Mac OS (don't have any Apple hardware, and Gina always tested on Mac) - fortunately, Mac OS has suitable `sed` and `awk` versions. The (huge) downside of ***@***.***@` is that one is forced to run `make`; the script won't work without it any longer. Second: If you automate this, do you assume `gsed` is available, or even implement both `gsed` and the other workaround?! To me, this adds a lot of complexity without much benefit.
Yes, NetBSD is the sole platform that I use, dev work probably not
but it would be still nice if we're able to easily test it! :)
I'm mostly speaking from a pkgsrc packaging/maintainer perspective
and, apart adjusting sed and other small adjustments^[0] all the
todotxt 2.11.0 tests passes!
But, yes, I can understand the arguments about @Sed@ that can
introduce complexity and further workarounds and probably we can
just maintain the `sed' adjustments as it is now locally on
pkgsrc.^[1]
Thank you!
[0]: The only real patch that I have added is the logic to try `date -r`
on every other platforms:
<http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/pkgsrc/time/todotxt/patches/patch-tests_test-lib.sh?rev=1.1>
[1]: And, it seems that FreeBSD ports package doesn't patch it:
<https://svnweb.freebsd.org/ports/head/deskutils/todo/Makefile>
|
I created a linked PR that solves this, but it does not export the function for use by add-ons. This is because the new |
On NetBSD (and probably other BSDs) sed is not supporting the inline mode todo.txt is using (sed -i).
A quick workaround is to replace "sed" with "gsed" in todo.sh. Please either let the user define which sed version to use, e.g. in .todo/config or don't use sed's inline mode.
The text was updated successfully, but these errors were encountered: