]> git.ipfire.org Git - thirdparty/bash.git/blame - examples/scripts.noah/bash_version.bash
Bash-4.2 patch 45
[thirdparty/bash.git] / examples / scripts.noah / bash_version.bash
CommitLineData
ccc6cda3
JA
1# bash_version.bash --- get major and minor components of bash version number
2# Author: Noah Friedman <friedman@prep.ai.mit.edu>
3# Created: 1993-01-26
4# Last modified: 1993-01-26
5# Public domain
6
7# Converted to bash v2 syntax by Chet Ramey
8
9# Commentary:
10# Code:
11
12#:docstring bash_version:
13# Usage: bash_version {major|minor}
14#
15# Echo the major or minor number of this version of bash on stdout, or
16# just echo $BASH_VERSION if no argument is given.
17#:end docstring:
18
19###;;;autoload
20function bash_version ()
21{
22 local major minor
23
24 case "$1" in
25 major) echo "${BASH_VERSION/.*/}" ;;
26 minor) major="${BASH_VERSION/.*/}"
27 minor="${BASH_VERSION#${major}.}"
28 echo "${minor%%.*}" ;;
29 patchlevel) minor="${BASH_VERSION#*.*.}"
30 echo "${minor%(*}" ;;
31 version) minor=${BASH_VERSION/#*.*./}
32 echo ${BASH_VERSION/%.$minor/} ;;
33 release) echo ${BASH_VERSION%(*} ;;
34 build) minor="${BASH_VERSION#*.*.*(}"
35 echo ${minor%)} ;;
36 *) echo "${BASH_VERSION}" ;;
37 esac
38}
39
40provide bash_version
41
42# bash_version.bash ends here