-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy patharch
executable file
·83 lines (54 loc) · 1.62 KB
/
arch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/perl
=begin metadata
Name: arch
Description: display system machine type
Author: Theo Van Dinter, [email protected]
License:
=end metadata
=cut
use strict;
use File::Basename qw(basename);
use Getopt::Std qw(getopts);
use POSIX qw(uname);
use constant EX_SUCCESS => 0;
use constant EX_FAILURE => 1;
my $Program = basename($0);
my %opt;
getopts('k', \%opt) or usage();
usage() if @ARGV;
# system ... (uname -s)
# arch ... (uname -m)
my ($system, $arch) = (uname())[0,4];
# sun3.* -> sun3, sun4.* -> sun4, etc. SunOS hooey.
# looks like `uname -m` eq `arch -k` on suns ...
unless ($opt{'k'}) {
$arch =~ s/^(sun\d+).*$/$1/;
}
$arch = "$system.$arch" if ( $system eq "OpenBSD" ); # OpenBSD hooey.
print "$arch\n";
exit EX_SUCCESS;
sub usage {
warn "usage: $Program [-k]\n";
exit EX_FAILURE;
}
=head1 NAME
arch - display system machine type
=head1 SYNOPSIS
B<arch> [ C<-k> ]
=head1 DESCRIPTION
arch displays the current system architecture type. It tends to be
equivilent to C<uname -m> (except on SunOS platforms, see B<NOTES>).
=head1 OPTIONS
C<-k> Displays kernel architecture on SunOS platforms.
=head1 NOTES
SunOS tends to differentiate between kernel and system architecture. I<uname
-m> will return kernel architecture. System architecture is the same
information except it doesn't include the trailing alpha chars. I.e.:
'sun4m' (kernel) = 'sun4' (system), 'sun3x' = 'sun3', etc, etc.
=head1 HISTORY
Perl version rewritten for the Perl Power Tools project from the
description of the arch program in OpenBSD.
=head1 AUTHOR
Theo Van Dinter ([email protected])
=head1 SEE ALSO
uname(1) uname(2) machine(1)