1 # bash_version.bash --- get major and minor components of bash version number
2 # Author: Noah Friedman <friedman@prep.ai.mit.edu>
4 # Last modified: 1993-01-26
7 # Converted to bash v2 syntax by Chet Ramey
12 #:docstring bash_version:
13 # Usage: bash_version {major|minor}
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.
20 function bash_version
()
25 major
) echo "${BASH_VERSION/.*/}" ;;
26 minor
) major
="${BASH_VERSION/.*/}"
27 minor
="${BASH_VERSION#${major}.}"
28 echo "${minor%%.*}" ;;
29 patchlevel
) minor
="${BASH_VERSION#*.*.}"
31 version
) minor
=${BASH_VERSION/#*.*./}
32 echo ${BASH_VERSION/%.$minor/} ;;
33 release
) echo ${BASH_VERSION%(*} ;;
34 build
) minor
="${BASH_VERSION#*.*.*(}"
36 *) echo "${BASH_VERSION}" ;;
42 # bash_version.bash ends here