From ba23a7f633d340a943f2ef35b3a2c4c59befb37c Mon Sep 17 00:00:00 2001 From: John Gebbie Date: Wed, 8 Feb 2023 14:05:04 +0000 Subject: [PATCH] add --version --- bin/tiles | 9 ++++++--- install.sh | 2 ++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/bin/tiles b/bin/tiles index 40399ea..eb2f646 100755 --- a/bin/tiles +++ b/bin/tiles @@ -1,13 +1,15 @@ #!/bin/sh +version=PLACEHOLDER usage() { echo 'Starts/stops the tiles desktop environment. Example: Start a session from the virtual console: startx /usr/bin/tiles ---quit Terminate the session. ---start Start a session, the default.' >&2 +--quit Terminate the session. +--start Start a session, the default. +--version Print the version and exit.' >&2 } -args="$(getopt -n tiles -o h -l help,quit,start -- "$@")" || exit +args="$(getopt -n tiles -o h -l help,quit,start,version -- "$@")" || exit eval set -- "$args" mode=start while :; do @@ -15,6 +17,7 @@ while :; do -h|--help) usage; exit;; --quit) mode=quit; shift;; --start) mode=start; shift;; + --version) printf %s\\n "$version"; exit;; --) shift; break;; esac done diff --git a/install.sh b/install.sh index 53ee6e1..4af1c55 100755 --- a/install.sh +++ b/install.sh @@ -1,5 +1,6 @@ #!/bin/sh # ./install.sh [DESTDIR] [BINDIR] +: "${TILES_VERSION="$(git describe --long --abbrev=12 --tags --dirty 2>/dev/null || echo 0.1)"}" if ! command -v scdoc >/dev/null; then echo 'you need the scdoc command (for compiling the manpage)' @@ -9,6 +10,7 @@ fi bin="$1/${2:-usr/local/bin}" mkdir -p "$bin" || exit cp bin/* "$bin" || exit +sed "s/^version=PLACEHOLDER$/version=$TILES_VERSION/" bin/tiles > "$bin/tiles" || exit cc -o "$bin/tiles-shell" tiles-shell.c || exit ln -sf "$bin/tiles-shell" "$1/usr/bin/tiles-shell" 2>/dev/null -- 2.38.5