Sun Aug 18 05:32:00 2019 UTC ()
pkgtools/url2pkg: run editor with line number only if supported

For example, ed doesn't support line numbers.


(rillig)
diff -r1.45 -r1.46 pkgsrc/pkgtools/url2pkg/files/url2pkg.pl

cvs diff -r1.45 -r1.46 pkgsrc/pkgtools/url2pkg/files/Attic/url2pkg.pl (expand / switch to unified diff)

--- pkgsrc/pkgtools/url2pkg/files/Attic/url2pkg.pl 2019/08/17 13:55:41 1.45
+++ pkgsrc/pkgtools/url2pkg/files/Attic/url2pkg.pl 2019/08/18 05:32:00 1.46
@@ -1,15 +1,15 @@ @@ -1,15 +1,15 @@
1#! @PERL@ 1#! @PERL@
2# $NetBSD: url2pkg.pl,v 1.45 2019/08/17 13:55:41 rillig Exp $ 2# $NetBSD: url2pkg.pl,v 1.46 2019/08/18 05:32:00 rillig Exp $
3# 3#
4 4
5# Copyright (c) 2010 The NetBSD Foundation, Inc. 5# Copyright (c) 2010 The NetBSD Foundation, Inc.
6# All rights reserved. 6# All rights reserved.
7# 7#
8# This code is derived from software contributed to The NetBSD Foundation 8# This code is derived from software contributed to The NetBSD Foundation
9# by Roland Illig. 9# by Roland Illig.
10# 10#
11# Redistribution and use in source and binary forms, with or without 11# Redistribution and use in source and binary forms, with or without
12# modification, are permitted provided that the following conditions 12# modification, are permitted provided that the following conditions
13# are met: 13# are met:
14# 1. Redistributions of source code must retain the above copyright 14# 1. Redistributions of source code must retain the above copyright
15# notice, this list of conditions and the following disclaimer. 15# notice, this list of conditions and the following disclaimer.
@@ -42,27 +42,32 @@ my $perllibdir = '@PERLLIBDIR@'; @@ -42,27 +42,32 @@ my $perllibdir = '@PERLLIBDIR@';
42 42
43use constant true => 1; 43use constant true => 1;
44use constant false => 0; 44use constant false => 0;
45 45
46# 46#
47# Some helper subroutines. 47# Some helper subroutines.
48# 48#
49 49
50sub run_editor($$) { 50sub run_editor($$) {
51 my ($fname, $lineno) = @_; 51 my ($fname, $lineno) = @_;
52 52
53 my $editor = $ENV{"PKGEDITOR"} || $ENV{"EDITOR"} || "vi"; 53 my $editor = $ENV{"PKGEDITOR"} || $ENV{"EDITOR"} || "vi";
54 54
55 system { $editor } ($editor, "+${lineno}", $fname); 55 my @args;
 56 push(@args, $editor);
 57 push(@args, "+$lineno") if $editor =~ qr"(^|/)(mcedit|nano|pico|vi|vim)$";
 58 push(@args, $fname);
 59
 60 system { $args[0] } (@args);
56} 61}
57 62
58sub get_maintainer() { 63sub get_maintainer() {
59 64
60 return $ENV{"PKGMAINTAINER"} || $ENV{"REPLYTO"} || "INSERT_YOUR_MAIL_ADDRESS_HERE"; 65 return $ENV{"PKGMAINTAINER"} || $ENV{"REPLYTO"} || "INSERT_YOUR_MAIL_ADDRESS_HERE";
61} 66}
62 67
63sub print_section($$) { 68sub print_section($$) {
64 my ($f, $vars) = @_; 69 my ($f, $vars) = @_;
65 70
66 if (scalar(@{$vars}) == 0) { 71 if (scalar(@{$vars}) == 0) {
67 return; 72 return;
68 } 73 }