lucc / nvimpager

Use nvim as a pager to view manpages, diffs, etc with nvim's syntax highlighting
Other
372 stars 20 forks source link

manpage installation fails on macos #50

Closed ofsaleem closed 3 years ago

ofsaleem commented 3 years ago

because macos uses BSD sed, sed behaves a little differently. so nvimpager installs and works just fine, but the manpage is not actually generated. if i try to manually create it with make nvimpager.1 i can see the error:

sed '1cnvimpager(1) "nvimpager v0.10.2-1-gd2b89c5"' nvimpager.md | scdoc > nvimpager.1
sed: 1: "1cnvimpager(1) "nvimpag ...": command c expects \ followed by text

i fixed the issue by installing gnu-sed (brew install gnu-sed) and replacing the sed on that line with gsed. then it worked fine, and i can man nvimpager properly.

lucc commented 3 years ago

Can you confirm if the branch fix-50 works?

ofsaleem commented 3 years ago

unfortunately same issue:

sed '1c\
    nvimpager(1) "nvimpager v0.10.2-2-g3739cb8"' nvimpager.md | scdoc > nvimpager.1
sed: 1: "1cnvimpager(1) "nvimpag ...": command c expects \ followed by text

EDIT: also, in case its useful, i should note that in either branch, the file is generated, its just not complete. here are the contents:

~ cat nvimpager.1 
.\" Generated by scdoc 1.11.1
.\" Complete documentation for this program is not available as a GNU info page
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.nh
.ad l
.\" Begin generated content:
lucc commented 3 years ago

Did you copy paste that sed command from the makefile or did you run the makefile? It seems there is a tab character at beginning of the line, which is there in the makefile but will be removed by make.

ofsaleem commented 3 years ago

I ran the makefile

lucc commented 3 years ago

Ok I tried another, hopefully more portable sed command. Strangely the CI on freebsd and osx did not complain about the sed command that I proposed above.

Can you try the new commit on the fix-50 branch?

ofsaleem commented 3 years ago

that seems to have worked! nvimpager.1 is created fully and no errors that i can see. thank you so much

eNV25 commented 3 years ago

I has the one who wrote that line.

Apparently the POSIX sed needs to have \ after the c command. Like this:

$ sed '1c\nvimpager(1) "nvimpager v0.10.2-2-g56871b2"' nvimpager.md

But GNU sed (with GNU extensions) doesn't complain if you use it wrong.

In the future you can use the --posix flag to see if the sed script works with POSIX.

$ sed --posix '1cnvimpager(1) "nvimpager v0.10.2-2-g56871b2"' nvimpager.md
sed: -e expression #1, char 3: expected \ after `a', `c' or `i'

This was in the man page but I didn't read it properly before.

lucc commented 3 years ago

@eNV25 no problem, I also used gnu make because I have it installed and only learned where it is not compatible with BSD when trying to run on mac & BSD on travis.

Thanks for the --posix tip.