Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 Jun 2023 20:58:12 +0000
From:      bugzilla-noreply@freebsd.org
To:        ports-bugs@FreeBSD.org
Subject:   [Bug 272054] [NEW PORT] sysutils/gh-md-toc: Easy TOC creation for GitHub README.md
Message-ID:  <bug-272054-7788-W8mga06jis@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-272054-7788@https.bugs.freebsd.org/bugzilla/>
References:  <bug-272054-7788@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D272054

Jes=C3=BAs Daniel Colmenares Oviedo <DtxdF@disroot.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 Attachment #242850|0                           |1
        is obsolete|                            |
 Attachment #243084|                            |maintainer-approval+
              Flags|                            |

--- Comment #2 from Jes=C3=BAs Daniel Colmenares Oviedo <DtxdF@disroot.org>=
 ---
Created attachment 243084
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D243084&action=
=3Dedit
gh-md-toc-0.8.0.patch

Thanks for reviewing my patch and sorry for taking so long to respond.

---

> does this script run with /bin/sh?  If yes, we could eliminate the bash d=
ependency.

Not by default, but I have patched gh-md-toc to work seamlessly with sh(1).

> could you patch the script to use fetch(1) instead of wget(1) or curl(1)?=
 This would permit elimination of these dependencies.

Unfortunately, fetch(1) doesn't allow you to set the headers that the Github
needs to set the token, but I've read gh-md-toc carefully and I think ftp/w=
get
doesn't make sense as the README says.

```
gh_toc_load() {
    local gh_url=3D$1

    if type curl &>/dev/null; then
        curl --user-agent "$gh_user_agent" -s "$gh_url"
    elif type wget &>/dev/null; then
        wget --user-agent=3D"$gh_user_agent" -qO- "$gh_url"
    else
        echo "Please, install 'curl' or 'wget' and try again."
        exit 1
    fi
}
```

The above code only makes sense if wget or curl is used depending on the us=
er's
preferences in the following code.

```
    OUTPUT=3D$(curl -s \
        --user-agent "$gh_user_agent" \
        --data-binary @"$gh_tmp_file_md" \
        -H "Content-Type:text/plain" \
        -H "$AUTHORIZATION" \
        "$URL")
```

The above code creates a dependency so the user must install ftp/curl and t=
he
gh_toc_load() will match curl first, so ftp/wget makes no sense. I simply
remove it to have less dependencies.

---

All other mentioned problems have been fixed and I have also patched gh-md-=
toc
in some parts that may create new problems, such as:

```
gh-md-toc --version
0.8.0

os:     FreeBSD 13.2-RELEASE
kernel: 1302001
shell:  /bin/csh

grep : grep (BSD grep, GNU compatible) 2.6.0-FreeBSD
awk  : awk version 20210215
sed  : sed (BSD sed)
fetch: fetch (BSD fetch)
```

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-272054-7788-W8mga06jis>