/etc/init.d/tc-functions uses /usr/bin/autoscan-devices, which is a separate executable. Compiled code versus shell script for executables is splitting hairs, I would say. The version command sources /etc/init.d/tc-functions, so why not update tc-functions and version so the work is done in tc-functions and version is just a quick way of calling the particular function:
tc@box:~$ diff tc-functions.orig /etc/init.d/tc-functions
--- tc-functions.orig
+++ /etc/init.d/tc-functions
@@ -273,10 +273,15 @@
} ' "$1"
}
-getMajorVer() {
-awk '{printf "%d", $1}' /usr/share/doc/tc/release.txt
+getFullVer() {
+verid=$(grep VERSION_ID /etc/os-release)
+echo ${verid#*=}
}
+getMajorVer() {
+fullver=$(getFullVer)
+echo ${fullver%.*}
+}
getBuild() {
BUILD=`uname -m`
tc@box:~$ diff version.orig /usr/bin/version
--- version.orig
+++ /usr/bin/version
@@ -6,8 +6,8 @@
. /etc/init.d/tc-functions
useBusybox
-RESULTS="$(cat /usr/share/doc/tc/release.txt)"
-while getopts cls OPTION
+RESULTS="$(getFullVer)"
+while getopts clsm OPTION
do
case ${OPTION} in
c) LATEST=`wget -q -O - $(cat /opt/tcemirror)/latest-$(getBuild) 2>/dev/null`
@@ -25,6 +25,9 @@
exit
;;
s) echo "${RESULTS##*_}"
+ exit
+ ;;
+ m) echo "$(getMajorVer)"
exit
;;
esac
Yes, I used the relatively new and more standard /etc/os-release instead of the classic TC specific /usr/share/doc/tc/release.txt.