diff options
Diffstat (limited to 'find-version.sh')
-rwxr-xr-x | find-version.sh | 8 |
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))))) |