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 it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 Bash is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License along
18 with Bash; see the file COPYING. If not, write to the Free Software
19 Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
27 #if defined (HAVE_UNISTD_H)
34 #include "conftypes.h"
47 extern char *dist_version;
48 extern int patch_level;
50 char *shell_name = "bash";
56 fprintf(stderr, "%s: usage: %s [-hrvpmlsx]\n", progname, progname);
67 if (progname = strrchr (argv[0], '/'))
73 while ((opt = getopt(argc, argv, "hrvmpslx")) != EOF)
81 oflags |= RFLAG; /* release */
84 oflags |= VFLAG; /* version */
87 oflags |= MFLAG; /* machtype */
90 oflags |= PFLAG; /* patchlevel */
92 case 's': /* short version string */
95 case 'l': /* long version string */
98 case 'x': /* extended version information */
116 /* default behavior */
120 if (oflags & (RFLAG|VFLAG))
122 strcpy (dv, dist_version);
123 rv = strchr (dv, '.');
131 else if (oflags & VFLAG)
133 else if (oflags & MFLAG)
134 printf ("%s\n", MACHTYPE);
135 else if (oflags & PFLAG)
136 printf ("%d\n", patch_level);
137 else if (oflags & SFLAG)
138 printf ("%s\n", shell_version_string ());
139 else if (oflags & LFLAG)
140 show_shell_version (0);
141 else if (oflags & XFLAG)
142 show_shell_version (1);