Skip to content

Commit

Permalink
make [puts] lookup channel ids instead of hardcoding them.
Browse files Browse the repository at this point in the history
  • Loading branch information
coke committed Jun 28, 2010
1 parent dd7abe2 commit dabdbaa
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/Partcl/commands/main.pm
Expand Up @@ -415,19 +415,24 @@ our sub proc(*@args) {
}

our sub puts(*@args) {
our %CHANNELS;

my $nl := 1;
if @args[0] eq '-nonewline' {
@args.shift; $nl := 0;
}
if @args[0] eq 'stdout' { @args.shift }
if @args[0] eq 'stderr' {
@args.shift;
pir::printerr(@args[0]);
pir::printerr("\n") if $nl;
my $channelId;
if +@args == 1 {
$channelId := 'stdout';
} else {
pir::print(@args[0]);
pir::print("\n") if $nl;
}
$channelId := @args.shift;
}
my $chanObj := %CHANNELS{$channelId};
if (! pir::defined($chanObj) ) {
error("can not find channel named \"$channelId\"");
}
pir::print__vps($chanObj, @args[0]);
pir::print__vps($chanObj, "\n") if $nl;
'';
}

Expand Down

0 comments on commit dabdbaa

Please sign in to comment.