blob: a34368184f9ce8875e40b95bbb542f1507151e1c [file] [log] [blame]
Allen Martin2051ff32012-08-15 11:38:53 +00001#!/bin/sh
2#
3# binutils-version [-p] gas-command
4#
5# Prints the binutils version of `gas-command' in a canonical 4-digit form
6# such as `0222' for binutils 2.22
7#
8
9gas="$*"
10
11if [ ${#gas} -eq 0 ]; then
12 echo "Error: No assembler specified."
13 printf "Usage:\n\t$0 <gas-command>\n"
14 exit 1
15fi
16
Bill Pringlemeirb6b1b442015-01-07 10:34:15 -050017version_string=$($gas --version | head -1 | \
18 sed -e 's/(.*)//; s/[^0-9.]*\([0-9.]*\).*/\1/')
Masahiro Yamada73c25752014-12-25 11:09:44 +090019
20MAJOR=$(echo $version_string | cut -d . -f 1)
21MINOR=$(echo $version_string | cut -d . -f 2)
Allen Martin2051ff32012-08-15 11:38:53 +000022
23printf "%02d%02d\\n" $MAJOR $MINOR