blob: 3fa4aeb2f236496a58c404497a09345b5e2b1641 [file] [log] [blame]
Jari Aalto726f6381996-08-26 18:22:31 +00001/* version.c -- distribution and version numbers. */
2
Chet Rameyac50fba2014-02-26 09:36:43 -05003/* Copyright (C) 1989-2013 Free Software Foundation, Inc.
Jari Aalto726f6381996-08-26 18:22:31 +00004
5 This file is part of GNU Bash, the Bourne Again SHell.
6
Jari Aalto31859422009-01-12 13:36:28 +00007 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.
Jari Aalto726f6381996-08-26 18:22:31 +000011
Jari Aalto31859422009-01-12 13:36:28 +000012 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.
Jari Aalto726f6381996-08-26 18:22:31 +000016
Jari Aalto31859422009-01-12 13:36:28 +000017 You should have received a copy of the GNU General Public License
18 along with Bash. If not, see <http://www.gnu.org/licenses/>.
19*/
Jari Aalto726f6381996-08-26 18:22:31 +000020
Jari Aaltof73dda02001-11-13 17:56:06 +000021#include <config.h>
22
Jari Aaltoccc6cda1996-12-23 17:02:34 +000023#include <stdio.h>
24
Jari Aaltof73dda02001-11-13 17:56:06 +000025#include "stdc.h"
26
Jari Aalto726f6381996-08-26 18:22:31 +000027#include "version.h"
Jari Aaltof73dda02001-11-13 17:56:06 +000028#include "patchlevel.h"
29#include "conftypes.h"
Jari Aalto726f6381996-08-26 18:22:31 +000030
Jari Aaltob80f6442004-07-27 13:29:18 +000031#include "bashintl.h"
32
Jari Aaltoccc6cda1996-12-23 17:02:34 +000033extern char *shell_name;
34
35/* Defines from version.h */
Jari Aalto31859422009-01-12 13:36:28 +000036const char * const dist_version = DISTVERSION;
37const int patch_level = PATCHLEVEL;
38const int build_version = BUILDVERSION;
Jari Aaltoccc6cda1996-12-23 17:02:34 +000039#ifdef RELSTATUS
Jari Aalto31859422009-01-12 13:36:28 +000040const char * const release_status = RELSTATUS;
Jari Aaltoccc6cda1996-12-23 17:02:34 +000041#else
Jari Aalto31859422009-01-12 13:36:28 +000042const char * const release_status = (char *)0;
Jari Aaltoccc6cda1996-12-23 17:02:34 +000043#endif
Jari Aalto31859422009-01-12 13:36:28 +000044const char * const sccs_version = SCCSVERSION;
45
Chet Rameyac50fba2014-02-26 09:36:43 -050046const char * const bash_copyright = N_("Copyright (C) 2013 Free Software Foundation, Inc.");
Jari Aalto31859422009-01-12 13:36:28 +000047const char * const bash_license = N_("License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n");
Jari Aaltoccc6cda1996-12-23 17:02:34 +000048
Jari Aaltof1be6662008-11-18 13:15:12 +000049/* If == 31, shell compatible with bash-3.1, == 32 with bash-3.2, and so on */
Jari Aalto31859422009-01-12 13:36:28 +000050int shell_compatibility_level = DEFAULT_COMPAT_LEVEL;
Jari Aaltof1be6662008-11-18 13:15:12 +000051
Jari Aaltoccc6cda1996-12-23 17:02:34 +000052/* Functions for getting, setting, and displaying the shell version. */
53
Jari Aaltob80f6442004-07-27 13:29:18 +000054/* Forward declarations so we don't have to include externs.h */
55extern char *shell_version_string __P((void));
56extern void show_shell_version __P((int));
57
Jari Aaltoccc6cda1996-12-23 17:02:34 +000058/* Give version information about this shell. */
59char *
60shell_version_string ()
61{
62 static char tt[32] = { '\0' };
63
64 if (tt[0] == '\0')
65 {
66 if (release_status)
Jari Aaltob80f6442004-07-27 13:29:18 +000067#if defined (HAVE_SNPRINTF)
68 snprintf (tt, sizeof (tt), "%s.%d(%d)-%s", dist_version, patch_level, build_version, release_status);
69#else
Jari Aaltoccc6cda1996-12-23 17:02:34 +000070 sprintf (tt, "%s.%d(%d)-%s", dist_version, patch_level, build_version, release_status);
Jari Aaltob80f6442004-07-27 13:29:18 +000071#endif
Jari Aaltoccc6cda1996-12-23 17:02:34 +000072 else
Jari Aaltob80f6442004-07-27 13:29:18 +000073#if defined (HAVE_SNPRINTF)
74 snprintf (tt, sizeof (tt), "%s.%d(%d)", dist_version, patch_level, build_version);
75#else
Jari Aaltoccc6cda1996-12-23 17:02:34 +000076 sprintf (tt, "%s.%d(%d)", dist_version, patch_level, build_version);
Jari Aaltob80f6442004-07-27 13:29:18 +000077#endif
Jari Aaltoccc6cda1996-12-23 17:02:34 +000078 }
79 return tt;
80}
81
Jari Aaltoccc6cda1996-12-23 17:02:34 +000082void
83show_shell_version (extended)
84 int extended;
85{
Jari Aalto31859422009-01-12 13:36:28 +000086 printf (_("GNU bash, version %s (%s)\n"), shell_version_string (), MACHTYPE);
Jari Aaltoccc6cda1996-12-23 17:02:34 +000087 if (extended)
Jari Aalto31859422009-01-12 13:36:28 +000088 {
89 printf ("%s\n", _(bash_copyright));
90 printf ("%s\n", _(bash_license));
Chet Rameyac50fba2014-02-26 09:36:43 -050091 printf ("%s\n", _("This is free software; you are free to change and redistribute it."));
92 printf ("%s\n", _("There is NO WARRANTY, to the extent permitted by law."));
Jari Aalto31859422009-01-12 13:36:28 +000093 }
Jari Aaltoccc6cda1996-12-23 17:02:34 +000094}