1 /* bashversion.c -- Display bash version information. */
3 /* Copyright (C) 2001 Free Software Foundation, Inc.
5 This file is part of GNU Bash, the Bourne Again SHell.
7 Bash is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 Bash is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with Bash. If not, see <http://www.gnu.org/licenses/>.
27 #if defined (HAVE_UNISTD_H)
34 #include "conftypes.h"
47 extern char *dist_version;
48 extern int patch_level;
50 extern char *shell_version_string __P((void));
51 extern void show_shell_version __P((int));
53 char *shell_name = "bash";
59 fprintf(stderr, "%s: usage: %s [-hrvpmlsx]\n", progname, progname);
70 if (progname = strrchr (argv[0], '/'))
76 while ((opt = getopt(argc, argv, "hrvmpslx")) != EOF)
84 oflags |= RFLAG; /* release */
87 oflags |= VFLAG; /* version */
90 oflags |= MFLAG; /* machtype */
93 oflags |= PFLAG; /* patchlevel */
95 case 's': /* short version string */
98 case 'l': /* long version string */
101 case 'x': /* extended version information */
119 /* default behavior */
123 if (oflags & (RFLAG|VFLAG))
125 strcpy (dv, dist_version);
126 rv = strchr (dv, '.');
134 else if (oflags & VFLAG)
136 else if (oflags & MFLAG)
137 printf ("%s\n", MACHTYPE);
138 else if (oflags & PFLAG)
139 printf ("%d\n", patch_level);
140 else if (oflags & SFLAG)
141 printf ("%s\n", shell_version_string ());
142 else if (oflags & LFLAG)
143 show_shell_version (0);
144 else if (oflags & XFLAG)
145 show_shell_version (1);