File: tripping.pl

package info (click to toggle)
rc 1.7.2-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,084 kB
  • ctags: 1,050
  • sloc: ansic: 7,631; sh: 1,123; yacc: 124; makefile: 100; perl: 13
file content (22 lines) | stat: -rw-r--r-- 412 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/perl

# Perl re-implementation of tripping.c

use strict;
use warnings;

use Fcntl qw(F_GETFL F_SETFL O_NONBLOCK);

my ($arg) = @ARGV;
$arg //= '';

if ($arg =~ /^0/) {
    print "tr\0ue\n";
} elsif ($arg =~ /^a/) {
    print "a\001ab\002b\n";
} elsif ($arg =~ /^n/) {
    my $flags = fcntl(STDIN, F_GETFL, 0) or die $!;
    fcntl(STDIN, F_SETFL, $flags | O_NONBLOCK) or die $!;
}

# vim:ts=4 sw=4 et