Advertisement
Guest User

Content of Exec

a guest
Jan 19th, 2013
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 4.76 KB | None | 0 0
  1. ubuntu@ubuntu:~$ cat /usr/games/cowsay
  2. #!/usr/bin/perl
  3.  
  4. ##
  5. ## Cowsay 3.03
  6. ##
  7. ## This file is part of cowsay.  (c) 1999-2000 Tony Monroe.
  8. ##
  9.  
  10. use Text::Tabs qw(expand);
  11. use Text::Wrap qw(wrap fill $columns);
  12. use File::Basename;
  13. use Getopt::Std;
  14. use Cwd;
  15.  
  16. if (${^UTF8LOCALE}) {
  17.     binmode STDIN, ':utf8';
  18.     binmode STDOUT, ':utf8';
  19.     require Encode;
  20.     eval { $_ = Encode::decode_utf8($_,1) } for @ARGV;
  21. }
  22.  
  23. $version = "3.03";
  24. $progname = basename($0);
  25. $eyes = "oo";
  26. $tongue = "  ";
  27. $cowpath = $ENV{'COWPATH'} || '/usr/share/cowsay/cows';
  28. @message = ();
  29. $thoughts = "";
  30.  
  31. ## Yeah, this is rude, I know.  But hopefully it gets around a nasty
  32. ## little version dependency.
  33.  
  34. $Text::Wrap::initial_tab = 8;
  35. $Text::Wrap::subsequent_tab = 8;
  36. $Text::Wrap::tabstop = 8;
  37.  
  38. ## One of these days, we'll get it ported to Windows.  Yeah, right.
  39.  
  40. if (($^O eq "MSWin32") or ($^O eq "Windows_NT")) {  ## Many perls, eek!
  41.     $pathsep = ';';
  42. } else {
  43.     $pathsep = ':';
  44. }
  45.  
  46. %opts = (
  47.     'e'     =>  'oo',
  48.     'f'     =>  'default.cow',
  49.     'n'     =>  0,
  50.     'T'     =>  '  ',
  51.     'W'     =>  40,
  52. );
  53.  
  54. getopts('bde:f:ghlLnNpstT:wW:y', \%opts);
  55.  
  56. &display_usage if $opts{'h'};
  57. &list_cowfiles if $opts{'l'};
  58.  
  59. $borg = $opts{'b'};
  60. $dead = $opts{'d'};
  61. $greedy = $opts{'g'};
  62. $paranoid = $opts{'p'};
  63. $stoned = $opts{'s'};
  64. $tired = $opts{'t'};
  65. $wired = $opts{'w'};
  66. $young = $opts{'y'};
  67. $eyes = substr($opts{'e'}, 0, 2);
  68. $tongue = substr($opts{'T'}, 0, 2);
  69. $the_cow = "";
  70.  
  71. &slurp_input;
  72. $Text::Wrap::columns = $opts{'W'};
  73. @message = ($opts{'n'} ? expand(@message) :
  74.         split("\n", fill("", "", @message)));
  75. &construct_balloon;
  76. &construct_face;
  77. &get_cow;
  78. print @balloon_lines;
  79. print $the_cow;
  80.  
  81. sub list_cowfiles {
  82.     my $basedir;
  83.     my @dirfiles;
  84.     chop($basedir = cwd);
  85.     for my $d (split(/$pathsep/, $cowpath)) {
  86.     print "Cow files in $d:\n";
  87.     opendir(COWDIR, $d) || die "$0: Cannot open $d\n";
  88.     for my $file (readdir COWDIR) {
  89.         if ($file =~ s/\.cow$//) {
  90.         push(@dirfiles, $file);
  91.         }
  92.     }
  93.     closedir(COWDIR);
  94.     print wrap("", "", sort @dirfiles), "\n";
  95.     @dirfiles = ();
  96.     chdir($basedir);
  97.     }
  98.     exit(0);
  99. }
  100.  
  101. sub slurp_input {
  102.     unless ($ARGV[0]) {
  103.     chomp(@message = <STDIN>);
  104.     } else {
  105.     &display_usage if $opts{'n'};
  106.     @message = join(' ', @ARGV);
  107.     }
  108. }
  109.  
  110. sub maxlength {
  111.     my ($l, $m);
  112.     $m = -1;
  113.     for my $i (@_) {
  114.     $l = length $i;
  115.     $m = $l if ($l > $m);
  116.     }
  117. ##  maxlength patch from Jeronimo Pellegrini (Closes: #165218)
  118.     if ($m == -1) {
  119.     $m = 0;
  120.     }
  121.     return $m;
  122. }
  123.  
  124. sub construct_balloon {
  125.     my $max = &maxlength(@message);
  126.     my $max2 = $max + 2;    ## border space fudge.
  127.     my $format = "%s %-${max}s %s\n";
  128.     my @border; ## up-left, up-right, down-left, down-right, left, right
  129.     if ($0 =~ /think/i) {
  130.     $thoughts = 'o';
  131.     @border = qw[ ( ) ( ) ( ) ];
  132.     } elsif (@message < 2) {
  133.     $thoughts = '\\';
  134.     @border = qw[ < > ];
  135.     } else {
  136.     $thoughts = '\\';
  137.     if ($V and $V gt v5.6.0) {      # Thanks, perldelta.
  138.         @border = qw[ / \\ \\ / | | ];
  139.     } else {
  140.         @border = qw[ / \ \ / | | ];   
  141.     }
  142.     }
  143. ## no trailing spaces (#276144)
  144.     push(@balloon_lines,
  145.     " " . ("_" x $max2) . "\n" ,
  146.     sprintf($format, $border[0], $message[0], $border[1]),
  147.     (@message < 2 ? "" :
  148.         map { sprintf($format, $border[4], $_, $border[5]) }
  149.         @message[1 .. $#message - 1]),
  150.     (@message < 2 ? "" :
  151.         sprintf($format, $border[2], $message[$#message], $border[3])),
  152.         " " . ("-" x $max2) . "\n"
  153.     );
  154. }
  155.  
  156. sub construct_face {
  157.     if ($borg) { $eyes = "=="; }
  158.     if ($dead) { $eyes = "xx"; $tongue = "U "; }
  159.     if ($greedy) { $eyes = "\$\$"; }
  160.     if ($paranoid) { $eyes = "@@"; }
  161.     if ($stoned) { $eyes = "**"; $tongue = "U "; }
  162.     if ($tired) { $eyes = "--"; }
  163.     if ($wired) { $eyes = "OO"; }
  164.     if ($young) { $eyes = ".."; }
  165. }
  166.  
  167. sub get_cow {
  168. ##
  169. ## Get a cow from the specified cowfile; otherwise use the default cow
  170. ## which was defined above in $the_cow.
  171. ##
  172.     my $f = $opts{'f'};
  173.     my $full = "";
  174.     if ($opts{'f'} =~ m,/,) {
  175.     $full = $opts{'f'};
  176.     } else {
  177.     for my $d (split(/:/, $cowpath)) {
  178.         if (-f "$d/$f") {
  179.         $full = "$d/$f";
  180.         last;
  181.         } elsif (-f "$d/$f.cow") {
  182.         $full = "$d/$f.cow";
  183.         last;
  184.         }
  185.     }
  186.     if ($full eq "") {
  187.         die "$progname: Could not find $f cowfile!\n";
  188.     }
  189.     }
  190.     do $full;
  191.     die "$progname: $@\n" if $@;
  192. }
  193.  
  194. sub display_usage {
  195.     die <<EOF;
  196. cow{say,think} version $version, (c) 1999 Tony Monroe
  197. Usage: $progname [-bdgpstwy] [-h] [-e eyes] [-f cowfile]
  198.           [-l] [-n] [-T tongue] [-W wrapcolumn] [message]
  199. EOF
  200. }
  201. ubuntu@ubuntu:~$ cat /usr/bin/opera-next
  202. #!/bin/sh
  203. export OPERA_DIR=${OPERA_DIR:-/usr/share/opera-next}
  204. export OPERA_PERSONALDIR=${OPERA_PERSONALDIR:-$HOME/.opera-next}
  205. exec /usr/lib/opera-next/opera-next "$@"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement