summaryrefslogtreecommitdiff
path: root/find-version.sh
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2022-12-14 23:48:22 +0800
committerJSDurand <mmemmew@gmail.com>2022-12-14 23:48:22 +0800
commit9f1c88b863e247da3cd60d2792a7a13b18e25e53 (patch)
treed29c0e19793a88a1de6898fdfd2a376fca21378f /find-version.sh
parentcb7bcfad4ab0041aaf3fde3185e27ee46bb37788 (diff)
a temporary check point
just to save things in a commit
Diffstat (limited to 'find-version.sh')
-rwxr-xr-xfind-version.sh8
1 files changed, 7 insertions, 1 deletions
diff --git a/find-version.sh b/find-version.sh
index 4ac390e..99aa538 100755
--- a/find-version.sh
+++ b/find-version.sh
@@ -2,18 +2,24 @@
":"; exec emacs --quick --script "$0" -- "$@" # -*- mode: emacs-lisp; lexical-binding: t; -*-
(with-temp-buffer
+ ;; the version information is stored in the Cargo.toml file.
(insert-file-contents "Cargo.toml")
(goto-char (point-min))
(cond
+ ;; search for the version assignment statement
((search-forward "version =" nil t)
- (re-search-forward " *" (line-end-position) t)
+ ;; skip spaces
+ (re-search-forward "[[:space:]]*" (line-end-position) t)
+ ;; check it starts with a double quote
(cond
((= (char-after) 34))
((error "Invalid syntax at %d" (point))))
(let ((end (line-end-position)))
+ ;; and check it ends with a double quote as well
(cond
((= (char-before end) 34))
((error "Invalid syntax at %d" (1- end))))
+ ;; then print the bare version string out without delimiters
(princ
(buffer-substring-no-properties
(1+ (point)) (1- end)))))