Skip to content
Konfekt edited this page Apr 10, 2021 · 2 revisions

Below shell script updates the crossref binary on Linux (in ~/bin) and man page.

#!/usr/bin/env sh

# debug output and exit on error or use of undeclared variable or pipe error:
set -o xtrace -o errtrace -o errexit -o nounset -o pipefail

latest_tag="$(curl --location --head https://github.com/lierdakil/pandoc-crossref/releases/latest | grep -i location: | sed 's/^.*\/tag\/\([^\/]*\)\r$/\1/')"
filename=pandoc-crossref-Linux.tar.xz
uri_to_download="https://github.com/lierdakil/pandoc-crossref/releases/download/${latest_tag}/${filename}"

repo="$HOME/bin/repos/pandoc-crossref"
mkdir --parents "$repo"

{
cd "$(mktemp --directory "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX")"
    curl --fail --show-error --remote-name --location "$uri_to_download"
    env XZ_OPT=-T0 tar --xz -xvf "$filename"
    chmod a+x pandoc-crossref
    cp pandoc-crossref "$repo"/
    cp pandoc-crossref.1 "$repo"/
}

if [ ! -x "${repo}/pandoc-crossref" ]; then
    echo '"pandoc-crossref" was not successfully installed!' >&2
    # DISPLAY=:0 notify-send --urgency=critical "Failed updating pandoc-crossref!
      # Run $0 to check."
    exit 2
fi

Below shell script updates the pandoc binary (on Linux 64 bit) to its latest version that the latest pandoc-crossref version is linked to.

#!/usr/bin/env bash

# debug output and exit on error or use of undeclared variable or pipe error:
set -o xtrace -o errtrace -o errexit -o nounset -o pipefail

repo="$HOME/bin/repos/pandoc"
mkdir --parents "$repo"

latest_tag="$(curl --location --head https://github.com/jgm/pandoc/releases/latest | grep -i location: | sed 's/^.*\/tag\/\([^\/]*\)\r$/\1/')"
filename=pandoc-${latest_tag}-linux-amd64.tar.gz
uri_to_download="https://github.com/jgm/pandoc/releases/download/${latest_tag}/${filename}"

(
cd "$(mktemp --directory "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX")"
    curl --fail --show-error --remote-name --location "$uri_to_download"
    env XZ_OPT=-T0 tar --gzip -xvf "$filename"
    chmod a+x pandoc-${latest_tag}/bin/pandoc
    cp        pandoc-${latest_tag}/bin/pandoc "$repo"/
    cp        pandoc-${latest_tag}/share/man/man1/pandoc.1.gz "$repo"/
)

if [ ! -x "${repo}/pandoc" ]; then
  echo '"pandoc" was not successfully installed!' >&2
  exit 2
fi
Clone this wiki locally