diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2007-05-05 10:40:45 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2007-05-05 10:40:45 +0000 |
commit | 4a31d0bfa582bbcb0f3481382d21455c264cb1a5 (patch) | |
tree | 0abc2448a19140281a1e036d823b24deb1cccf8b /usr.sbin | |
parent | afb45593a7773914f611f8aedf36ad18262e1c5e (diff) |
split copy_subst to allow for existing filehandle.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/pkg_add/pkg_create | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/usr.sbin/pkg_add/pkg_create b/usr.sbin/pkg_add/pkg_create index 2809a8450ec..b819df11c13 100644 --- a/usr.sbin/pkg_add/pkg_create +++ b/usr.sbin/pkg_add/pkg_create @@ -1,6 +1,6 @@ #! /usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: pkg_create,v 1.89 2007/05/04 19:40:37 espie Exp $ +# $OpenBSD: pkg_create,v 1.90 2007/05/05 10:40:44 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -321,16 +321,21 @@ sub dosubst return $_; } -sub copy_subst +sub copy_subst_fh { - my ($srcname, $mode, $destname) = @_; + my ($srcname, $dest) = @_; open my $src, '<', $srcname or die "can't open $srcname"; - open my $dest, $mode, $destname or die "can't open $destname"; local $_; while (<$src>) { print $dest dosubst($_); } } +sub copy_subst +{ + my ($srcname, $mode, $destname) = @_; + open my $dest, $mode, $destname or die "can't open $destname"; + copy_subst_fh($srcname, $dest); +} our ($opt_p, $opt_f, $opt_c, $opt_d, $opt_v, $opt_i, $opt_k, $opt_r, $opt_S, $opt_h, $opt_s, $opt_O, $opt_A, $opt_L, |