RexOps / RexOps/Rex

Don't use local @ARGV=...; <> for slurping file contents

Open
#1,466 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Perl
Stars
737
Forks
214
PR merge metrics
No merged PRs in 30d

Description

Migrated from rt.cpan.org #98871 (status was 'new')

Requestors:

  • SREZIC@cpan.org (@eserte)

From srezic@cpan.org (@eserte) on 2014-09-14 13:47:34
:

Rex::Config is using something like

@ARGV = ...; <>

to slurp file contents, and this may happen during compile time (e.g. read_ssh_config is called in import(), so a "use Rex::Config" would trigger this code). Unfortunately this means that a currently active <> loop would break. See https://github.com/cpan-testers/CPAN-Reporter/issues/20 for an issue where this actually happens.

Probably it's safer to use instead

do { open my $fh, $file or die $!; undef $/; <$fh> }

even if it's slightly longer. Or alternatively

use IO::File ();
join '', IO::File->new($file)->getlines;

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Search the Rex::Config implementation for the local @ARGV assignment and the read_ssh_config path called from import(). Replace the slurp approach so reading configuration content does not alter the caller's active <> loop; verify the affected configuration-reading behavior with the existing tests, if present.

Written by the indexing model from the issue text.

Assessment

Tech stack
perl
Domain
devops
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.