<commit_before>my class IO::Path { ... }
my class IO::Special { ... }
my class Proc { ... }

# Will be removed together with pipe() and open(:p).
my class Proc::Status {
    has $.exitcode = -1;  # distinguish uninitialized from 0 status
    has $.pid;
    has $.signal;

    method exit {
        DEPRECATED('Proc::Status.exitcode', |<2015.03 2015.09>);
        $!exitcode;
    }

    proto method status(|) { * }
    multi method status($new_status) {
        $!exitcode = $new_status +> 8;
        $!signal   = $new_status +& 0xFF;
    }
    multi method status(Proc::Status:D:)  { ($!exitcode +< 8) +| $!signal }
    multi method Numeric(Proc::Status:D:) { $!exitcode }
    multi method Bool(Proc::Status:D:)    { $!exitcode == 0 }
}

my class IO::Handle does IO {
    has $.path;
    has $!PIO;
    has int $.ins;
    has $.chomp is rw = Bool::True;
    has $.nl    = "\n";
    has int $!pipe;

    method pipe(IO::Handle:D: |c) {
        DEPRECATED('shell() or run() with :in, :out or :err', |<2015.07 2015.09>);
        self.open(:p, :nodepr, |c);
    }

    method open(IO::Handle:D:
      :$p, :$r, :$w, :$x, :$a, :$update,
      :$rw, :$rx, :$ra,
      :$mode is copy,
      :$create is copy,
      :$append is copy,
      :$truncate is copy,
      :$exclusive is copy,
      :$bin,
      :$chomp = True,
      :$enc   = 'utf8',
      :$nl    = "\n",
      :$nodepr,
    ) {

        $mode //= do {
            when so $p { 'pipe' }

            when so ($r && $w) || $rw { $create              = True; 'rw' }
            when so ($r && $x) || $rx { $create = $exclusive = True; 'rw' }
            when so ($r && $a) || $ra { $create = $append    = True; 'rw' }

            when so $r { 'ro' }
            when so $w { $create = $truncate  = True; 'wo' }
            when so $x { $create = $exclusive = True; 'wo' }
            when so $a { $create = $append    = True; 'wo' }

            when so $update { 'rw' }

            default { 'ro' }
        }

        if $!path eq '-' {
            $!path = IO::Special.new:
                what => do given $mode {
                    when 'ro' { '<STDIN>'  }
                    when 'wo' { '<STDOUT>' }
                    default {
                        die "Cannot open standard stream in mode '$_'";
                    }
                }
        }

        if nqp::istype($!path, IO::Special) {
            my $what := $!path.what;
            if $what eq '<STDIN>' {
                $!PIO := nqp::getstdin();
            }
            elsif $what eq '<STDOUT>' {
                $!PIO := nqp::getstdout();
            }
            elsif $what eq '<STDERR>' {
                $!PIO := nqp::getstderr();
            }
            else {
                die "Don't know how to open '$_' especially";
            }
            $!chomp = $chomp;
            nqp::setencoding($!PIO, NORMALIZE_ENCODING($enc)) unless $bin;
            return self;
        }

        fail (X::IO::Directory.new(:$!path, :trying<open>))
          if $!path.e && $!path.d;

        if $mode eq 'pipe' {
            DEPRECATED('shell(...)/run(...) with :in, :out or :err', |<2015.07 2015.09>, :what(':p for pipe')) unless $nodepr;<commit_msg>fix deprecation begin for pipe()/open(:p)<commit_after>my class IO::Path { ... }
my class IO::Special { ... }
my class Proc { ... }

# Will be removed together with pipe() and open(:p).
my class Proc::Status {
    has $.exitcode = -1;  # distinguish uninitialized from 0 status
    has $.pid;
    has $.signal;

    method exit {
        DEPRECATED('Proc::Status.exitcode', |<2015.03 2015.09>);
        $!exitcode;
    }

    proto method status(|) { * }
    multi method status($new_status) {
        $!exitcode = $new_status +> 8;
        $!signal   = $new_status +& 0xFF;
    }
    multi method status(Proc::Status:D:)  { ($!exitcode +< 8) +| $!signal }
    multi method Numeric(Proc::Status:D:) { $!exitcode }
    multi method Bool(Proc::Status:D:)    { $!exitcode == 0 }
}

my class IO::Handle does IO {
    has $.path;
    has $!PIO;
    has int $.ins;
    has $.chomp is rw = Bool::True;
    has $.nl    = "\n";
    has int $!pipe;

    method pipe(IO::Handle:D: |c) {
        DEPRECATED('shell() or run() with :in, :out or :err', |<2015.06 2015.09>);
        self.open(:p, :nodepr, |c);
    }

    method open(IO::Handle:D:
      :$p, :$r, :$w, :$x, :$a, :$update,
      :$rw, :$rx, :$ra,
      :$mode is copy,
      :$create is copy,
      :$append is copy,
      :$truncate is copy,
      :$exclusive is copy,
      :$bin,
      :$chomp = True,
      :$enc   = 'utf8',
      :$nl    = "\n",
      :$nodepr,
    ) {

        $mode //= do {
            when so $p { 'pipe' }

            when so ($r && $w) || $rw { $create              = True; 'rw' }
            when so ($r && $x) || $rx { $create = $exclusive = True; 'rw' }
            when so ($r && $a) || $ra { $create = $append    = True; 'rw' }

            when so $r { 'ro' }
            when so $w { $create = $truncate  = True; 'wo' }
            when so $x { $create = $exclusive = True; 'wo' }
            when so $a { $create = $append    = True; 'wo' }

            when so $update { 'rw' }

            default { 'ro' }
        }

        if $!path eq '-' {
            $!path = IO::Special.new:
                what => do given $mode {
                    when 'ro' { '<STDIN>'  }
                    when 'wo' { '<STDOUT>' }
                    default {
                        die "Cannot open standard stream in mode '$_'";
                    }
                }
        }

        if nqp::istype($!path, IO::Special) {
            my $what := $!path.what;
            if $what eq '<STDIN>' {
                $!PIO := nqp::getstdin();
            }
            elsif $what eq '<STDOUT>' {
                $!PIO := nqp::getstdout();
            }
            elsif $what eq '<STDERR>' {
                $!PIO := nqp::getstderr();
            }
            else {
                die "Don't know how to open '$_' especially";
            }
            $!chomp = $chomp;
            nqp::setencoding($!PIO, NORMALIZE_ENCODING($enc)) unless $bin;
            return self;
        }

        fail (X::IO::Directory.new(:$!path, :trying<open>))
          if $!path.e && $!path.d;

        if $mode eq 'pipe' {
            DEPRECATED('shell(...)/run(...) with :in, :out or :err', |<2015.06 2015.09>, :what(':p for pipe')) unless $nodepr;
{'fraction_non_alphanumeric': 0.17979987492182614, 'fraction_numerical': 0.01344590368980613, 'mean_word_length': 1.5284584980237155, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '474459', 'n_tokens_mistral': 2277, 'n_tokens_neox': 2121, 'n_words': 579}