3 # Simple program to make new version numbers for the shell.
4 # Big deal, but it was getting out of hand to do everything
5 # in the makefile. This creates a file named by the -o option,
6 # otherwise everything is echoed to the standard output.
9 USAGE="$PROGNAME [-b] -d version -p patchlevel [-s status]"
11 while [ $# -gt 0 ]; do
13 -o) shift; OUTFILE=$1; shift ;;
14 -b) shift; inc_build=yes ;;
15 -s) shift; rel_status=$1; shift ;;
16 -p) shift; patch_level=$1; shift ;;
17 -d) shift; dist_version=$1; shift ;;
18 *) echo "$PROGNAME: usage: $USAGE" >&2 ; exit 2 ;;
23 if [ -z "$dist_version" ]; then
24 echo "${PROGNAME}: required argument -d missing" >&2
25 echo "$PROGNAME: usage: $USAGE" >&2
29 if [ -z "$patch_level" ]; then
30 echo "${PROGNAME}: required argument -p missing" >&2
31 echo "$PROGNAME: usage: $USAGE" >&2
36 if [ -z "$rel_status" ]; then
41 if [ -r .build ]; then
42 build_ver=`cat .build`
44 if [ -z "$build_ver" ]; then
48 # increment the build version if that's what's required
50 if [ -n "$inc_build" ]; then
51 build_ver=`expr $build_ver + 1`
54 # If we have an output file specified, make it the standard output
55 if [ -n "$OUTFILE" ]; then
56 if exec >$OUTFILE; then
59 echo "${PROGNAME}: cannot redirect standard output to $OUTFILE" >&2
64 # Output the leading comment.
65 echo "/* Version control for the shell. This file gets changed when you say"
66 echo " \`make version.h' to the Makefile. It is created by mkversion. */"
68 # Output the distribution version
69 float_dist=`echo $dist_version | awk '{printf "%.2f\n", $1}'`
72 echo "/* The distribution version number of this shell. */"
73 echo "#define DISTVERSION \"${float_dist}\""
75 # Output the patch level
77 echo "/* The patch level of this version of the shell. */"
78 echo "#define PATCHLEVEL ${patch_level}"
80 # Output the build version
82 echo "/* The last built version of this shell. */"
83 echo "#define BUILDVERSION ${build_ver}"
85 # Output the release status
87 echo "/* The release status of this shell. */"
88 echo "#define RELSTATUS \"${rel_status}\""
90 # Output the SCCS version string
91 sccs_string="${float_dist}.${patch_level}(${build_ver}) ${rel_status} GNU"
93 echo "/* A version string for use by sccs and the what command. */"
94 echo "#define SCCSVERSION \"@(#)Bash version ${sccs_string}\""
96 if [ -n "$inc_build" ]; then
97 # Make sure we can write to .build
98 if [ -f .build ] && [ ! -w .build ]; then
99 echo "$PROGNAME: cannot write to .build, not incrementing build version" >&2
101 echo "$build_ver" > .build