diff options
author | 2011-11-13 15:41:57 +0000 | |
---|---|---|
committer | 2011-11-13 15:41:57 +0000 | |
commit | ce5a451ef610dac33b551c1146be51771d1f6a99 (patch) | |
tree | cb04e8ea33e042c1c78bb11df9ff8e855a92a17d | |
parent | Make the man(7) page footer the same as in groff. (diff) | |
download | wireguard-openbsd-ce5a451ef610dac33b551c1146be51771d1f6a99.tar.xz wireguard-openbsd-ce5a451ef610dac33b551c1146be51771d1f6a99.zip |
The pkg_subst / SUBST_CMD has caused issues for some ports where
the $\ in files was replaced by $. Now only removes the \
in $\{[A-Za-z_]
Ok espie@
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Subst.pm | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Subst.pm b/usr.sbin/pkg_add/OpenBSD/Subst.pm index f1082facc58..d167dd0afcf 100644 --- a/usr.sbin/pkg_add/OpenBSD/Subst.pm +++ b/usr.sbin/pkg_add/OpenBSD/Subst.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Subst.pm,v 1.14 2010/12/24 09:04:14 espie Exp $ +# $OpenBSD: Subst.pm,v 1.15 2011/11/13 15:41:57 nigel Exp $ # # Copyright (c) 2008 Marc Espie <espie@openbsd.org> # @@ -64,20 +64,24 @@ sub do my $self = shift; my $_ = shift; return $_ unless m/\$/o; # optimization - while (my ($k, $v) = each %{$self->hash}) { + while ( my $k = (m/\$\{([A-Za-z_][^\}]*)\}/o)[0] ) { + my $v = $self->{$k}; + unless ( defined $v ) { $v = "\$\\\{$k\}"; } s/\$\{\Q$k\E\}/$v/g; } - s/\$\\/\$/go; + s/\$\\\{([A-Za-z_])/\$\{$1/go; return $_; } sub copy_fh2 { my ($self, $src, $dest) = @_; - my $_; - while (<$src>) { - print $dest $self->do($_); + my $_ = do { local $/; <$src> }; + while (my ($k, $v) = each %{$self}) { + s/\$\{\Q$k\E\}/$v/g; } + s/\$\\\{([A-Za-z_])/\$\{$1/go; + print $dest $_; } sub copy_fh |