mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-04 04:06:06 -05:00
Foot’s policy is to not set environment variables that identifies it (except the well-known and established `TERM` variable). We encourage applications to use terminfo to determine capabilities, or terminal queries, when available. Or, at least use terminal queries to detect the terminal and its version. Setting environment variables is a bad idea since they are inherited by all applications started by the terminal (which is the whole point). But, this includes other terminal emulators, making it very possible a terminal emulator gets mis-detected just because it was started from another terminal. Since there are a couple of terminal emulators that _do_ set TERM_PROGRAM and TERM_PROGRAM_VERSION, unset these environment variables to avoid being misdetected. Closes #1349
60 lines
1.6 KiB
Bash
Executable file
60 lines
1.6 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
if [ ${#} -ne 3 ]; then
|
|
echo "Usage: ${0} <default_version> <src_dir> <out_file>"
|
|
exit 1
|
|
fi
|
|
|
|
default_version=${1}
|
|
src_dir=${2}
|
|
out_file=${3}
|
|
|
|
# echo "default version: ${default_version}"
|
|
# echo "source directory: ${src_dir}"
|
|
# echo "output file: ${out_file}"
|
|
|
|
if [ -d "${src_dir}/.git" ] && command -v git > /dev/null; then
|
|
workdir=$(pwd)
|
|
cd "${src_dir}"
|
|
|
|
if git describe --tags > /dev/null 2>&1; then
|
|
git_version=$(git describe --always --tags)
|
|
else
|
|
# No tags available, happens in e.g. CI builds
|
|
git_version="${default_version}"
|
|
fi
|
|
|
|
git_branch=$(git rev-parse --abbrev-ref HEAD)
|
|
cd "${workdir}"
|
|
|
|
new_version="${git_version} ($(date "+%b %d %Y"), branch '${git_branch}')"
|
|
else
|
|
new_version="${default_version}"
|
|
extra=""
|
|
fi
|
|
|
|
major=$(echo "${new_version}" | sed -r 's/([0-9]+)\.([0-9]+)\.([0-9]+).*/\1/')
|
|
minor=$(echo "${new_version}" | sed -r 's/([0-9]+)\.([0-9]+)\.([0-9]+).*/\2/')
|
|
patch=$(echo "${new_version}" | sed -r 's/([0-9]+)\.([0-9]+)\.([0-9]+).*/\3/')
|
|
extra=$(echo "${new_version}" | sed -r 's/([0-9]+)\.([0-9]+)\.([0-9]+)(-([0-9]+-g[a-z0-9]+) .*)?.*/\5/')
|
|
|
|
new_version="#define FOOT_VERSION \"${new_version}\"
|
|
#define FOOT_MAJOR ${major}
|
|
#define FOOT_MINOR ${minor}
|
|
#define FOOT_PATCH ${patch}
|
|
#define FOOT_EXTRA \"${extra}\""
|
|
|
|
if [ -f "${out_file}" ]; then
|
|
old_version=$(cat "${out_file}")
|
|
else
|
|
old_version=""
|
|
fi
|
|
|
|
# echo "old version: ${old_version}"
|
|
# echo "new version: ${new_version}"
|
|
|
|
if [ "${old_version}" != "${new_version}" ]; then
|
|
echo "${new_version}" > "${out_file}"
|
|
fi
|