updated git and svn scripts
[xrzperl.git] / cmdcat
blob239e1673391029019bdfde3cda8a02054ee1dfd2
1 #!/usr/bin/perl -w
2 ###APPNAME: cmdcat
3 ###APPAUTHOR: xiaoranzzz
4 ###APPDATE: Fri Sep 21 22:33:33 2007
5 ###APPVER: 0.1
6 ###APPDESC: cat command source text
7 ###APPUSAGE: (cmdname)
8 ###APPEXAMPLE: cmdcat cmdinfo
9 ###APPOPTION:
10 use strict;
11 $ARGV[0]="--help" unless(@ARGV);
12 exit 0 unless(system("plhelp",$0,(@ARGV)));
14 my $support="application\/(x-awk|x-shellscript|text\/plain|x-perl)";
15 my $editor="cat";
16 my $cmdname=shift;
17 my $location=`which "$cmdname"`;
18 chomp($location);
19 die("Command not found: $cmdname\n") unless($location);
20 my $info=`file -biL "$location"`;
21 chomp($info);
22 $info =~ s/,.*$//g;
24 my $format="%-15s%s\n";
25 printf STDERR ($format,"Name:",$cmdname);
26 printf STDERR ($format,"FileType:",$info);
27 printf STDERR ($format,"Location:",$location);
28 printf STDERR ($format,"LinkTo:",readlink($location)) if(-l $location);
29 if ($info =~ m/^text\// or $info =~ m/$support/) {
30 system($editor,$location);
32 else {
33 print STDERR ("Not supported type\n");
34 my $answer="n";
35 read STDIN,$answer,1;
36 system($editor,$location) if (lc($answer) eq "y");