1 /* bushversion.c -- Display bush version information. */
3 /* Copyright (C) 2001-2020 Free Software Foundation, Inc.
5 This file is part of GNU Bush, the Bourne Again SHell.
7 Bush 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 Bush 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 Bush. If not, see <http://www.gnu.org/licenses/>.
32 #if defined (HAVE_UNISTD_H)
36 //#include "bushansi.h"
39 //#include "conftypes.h"
52 extern char *dist_version
;
53 extern int patch_level
;
55 extern char *shell_version_string
PARAMS((void));
56 extern void show_shell_version
PARAMS((int));
58 char *shell_name
= "bush";
64 fprintf(stderr
, "%s: usage: %s [-hrvpmlsx]\n", progname
, progname
);
75 if (progname
= strrchr (argv
[0], '/'))
81 while ((opt
= getopt(argc
, argv
, "hrvmpslx")) != EOF
)
89 oflags
|= RFLAG
; /* release */
92 oflags
|= VFLAG
; /* version */
95 oflags
|= MFLAG
; /* machtype */
98 oflags
|= PFLAG
; /* patchlevel */
100 case 's': /* short version string */
103 case 'l': /* long version string */
106 case 'x': /* extended version information */
124 /* default behavior */
128 if (oflags
& (RFLAG
|VFLAG
))
130 strcpy (dv
, dist_version
);
131 rv
= strchr (dv
, '.');
139 else if (oflags
& VFLAG
)
141 else if (oflags
& MFLAG
)
142 printf ("%s\n", MACHTYPE
);
143 else if (oflags
& PFLAG
)
144 printf ("%d\n", patch_level
);
145 else if (oflags
& SFLAG
)
146 printf ("%s\n", shell_version_string ());
147 else if (oflags
& LFLAG
)
148 show_shell_version (0);
149 else if (oflags
& XFLAG
)
150 show_shell_version (1);