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. */
29 #include "conftypes.h"
42 extern char *dist_version;
43 extern int patch_level;
45 char *shell_name = "bash";
51 fprintf(stderr, "%s: usage: %s [-hrvpmlsx]\n", progname, progname);
62 if (progname = strrchr (argv[0], '/'))
68 while ((opt = getopt(argc, argv, "hrvmpslx")) != EOF)
76 oflags |= RFLAG; /* release */
79 oflags |= VFLAG; /* version */
82 oflags |= MFLAG; /* machtype */
85 oflags |= PFLAG; /* patchlevel */
87 case 's': /* short version string */
90 case 'l': /* long version string */
93 case 'x': /* extended version information */
111 /* default behavior */
115 if (oflags & (RFLAG|VFLAG))
117 strcpy (dv, dist_version);
118 rv = strchr (dv, '.');
126 else if (oflags & VFLAG)
128 else if (oflags & MFLAG)
129 printf ("%s\n", MACHTYPE);
130 else if (oflags & PFLAG)
131 printf ("%d\n", patch_level);
132 else if (oflags & SFLAG)
133 printf ("%s\n", shell_version_string ());
134 else if (oflags & LFLAG)
135 show_shell_version (0);
136 else if (oflags & XFLAG)
137 show_shell_version (1);