[Libguestfs] [PATCH] Fix shebang in perl scripts

Pino Toscano ptoscano at redhat.com
Mon Oct 5 14:10:48 UTC 2015


Instead of hardcoding the location of perl (assuming it is installed in
/usr), use /usr/bin/env to run it, and thus picking it from $PATH.
This makes it possible to run these scripts also on installations with
perl in a different prefix than /usr.

Also, given that we want enable warnings on scripts, turn the -w
previously in shebang to explicit "use warnings;" in scripts which
didn't have it before.
---
 contrib/windows-icons.pl                       | 3 ++-
 examples/guestfs-performance.pod               | 3 ++-
 generator/bindtests.ml                         | 3 ++-
 perl/examples/create_disk.pl                   | 3 ++-
 perl/examples/inspect_vm.pl                    | 3 ++-
 pick-guests.pl.in                              | 3 ++-
 podwrapper.pl.in                               | 2 +-
 rescue/test-virt-rescue.pl                     | 3 ++-
 resize/test-virt-resize.pl                     | 2 +-
 tests/bigdirs/test-big-dirs.pl                 | 2 +-
 tests/btrfs/test-btrfs-misc.pl                 | 2 +-
 tests/btrfs/test-btrfs-subvolume-default.pl    | 2 +-
 tests/daemon/test-btrfs.pl                     | 2 +-
 tests/daemon/test-daemon-start.pl              | 2 +-
 tests/discard/test-blkdiscard.pl               | 2 +-
 tests/discard/test-discard.pl                  | 2 +-
 tests/discard/test-fstrim.pl                   | 2 +-
 tests/disk-labels/test-disk-labels.pl          | 2 +-
 tests/disks/test-max-disks.pl                  | 2 +-
 tests/events/test-console-debug.pl             | 2 +-
 tests/fuzz/fuzz-inspection.pl                  | 2 +-
 tests/guests/guest-aux/make-fedora-img.pl      | 2 +-
 tests/guests/guest-aux/make-guests-all-good.pl | 2 +-
 tests/hotplug/test-hot-add.pl                  | 2 +-
 tests/hotplug/test-hot-remove.pl               | 2 +-
 tests/hotplug/test-hotplug-repeated.pl         | 2 +-
 tests/journal/test-journal.pl                  | 2 +-
 tests/lvm/test-lvm-mapping.pl                  | 2 +-
 tests/nbd/test-nbd.pl                          | 2 +-
 tests/protocol/test-launch-race.pl             | 2 +-
 tests/regressions/test-noexec-stack.pl         | 2 +-
 tests/selinux/run-test.pl                      | 2 +-
 tests/syslinux/test-syslinux.pl                | 2 +-
 tests/tmpdirs/test-tmpdirs.pl                  | 2 +-
 tests/xfs/test-xfs-misc.pl                     | 2 +-
 tests/xml/rhbz701814.pl                        | 3 ++-
 tools/virt-list-filesystems                    | 2 +-
 tools/virt-list-partitions                     | 2 +-
 tools/virt-tar                                 | 2 +-
 tools/virt-win-reg                             | 2 +-
 40 files changed, 48 insertions(+), 40 deletions(-)

diff --git a/contrib/windows-icons.pl b/contrib/windows-icons.pl
index cb2de03..fc93af0 100755
--- a/contrib/windows-icons.pl
+++ b/contrib/windows-icons.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
 # libguestfs
 # Copyright (C) 2012 Red Hat Inc.
 #
@@ -24,6 +24,7 @@
 #   ./run ./contrib/windows-icons.pl /path/to/windows-disk.img
 
 use strict;
+use warnings;
 
 use Sys::Guestfs;
 use File::Temp qw{tempdir};
diff --git a/examples/guestfs-performance.pod b/examples/guestfs-performance.pod
index 7cf10aa..caa7535 100644
--- a/examples/guestfs-performance.pod
+++ b/examples/guestfs-performance.pod
@@ -322,10 +322,11 @@ L<http://rwmj.wordpress.com/2013/02/25/multiple-libguestfs-appliances-in-paralle
 L<http://rwmj.wordpress.com/2013/02/25/multiple-libguestfs-appliances-in-parallel-part-3/>
 L<http://rwmj.wordpress.com/2013/02/25/multiple-libguestfs-appliances-in-parallel-part-4/>
 
- #!/usr/bin/perl -w
+ #!/usr/bin/env perl
  
  use strict;
  use threads;
+ use warnings;
  use Sys::Guestfs;
  use Time::HiRes qw(time);
  
diff --git a/generator/bindtests.ml b/generator/bindtests.ml
index 5358ff1..0959704 100644
--- a/generator/bindtests.ml
+++ b/generator/bindtests.ml
@@ -370,11 +370,12 @@ let () =
   pr "print_endline \"EOF\"\n"
 
 and generate_perl_bindtests () =
-  pr "#!/usr/bin/perl -w\n";
+  pr "#!/usr/bin/env perl\n";
   generate_header HashStyle GPLv2plus;
 
   pr "\
 use strict;
+use warnings;
 
 use Sys::Guestfs;
 
diff --git a/perl/examples/create_disk.pl b/perl/examples/create_disk.pl
index 0b9fa8d..3b40683 100755
--- a/perl/examples/create_disk.pl
+++ b/perl/examples/create_disk.pl
@@ -1,8 +1,9 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
 
 # Example showing how to create a disk image.
 
 use strict;
+use warnings;
 use Sys::Guestfs;
 
 my $output = "disk.img";
diff --git a/perl/examples/inspect_vm.pl b/perl/examples/inspect_vm.pl
index 6d95b69..04fbae6 100755
--- a/perl/examples/inspect_vm.pl
+++ b/perl/examples/inspect_vm.pl
@@ -1,8 +1,9 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
 
 # Example showing how to inspect a virtual machine disk.
 
 use strict;
+use warnings;
 use Sys::Guestfs;
 
 if (@ARGV < 1) {
diff --git a/pick-guests.pl.in b/pick-guests.pl.in
index bfc97d8..1ccc04b 100755
--- a/pick-guests.pl.in
+++ b/pick-guests.pl.in
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
 # @configure_input@
 # Copyright (C) 2009-2015 Red Hat Inc.
 #
@@ -20,6 +20,7 @@
 # This is used by 'make check-valgrind-local-guests'.
 
 use strict;
+use warnings;
 
 use Sys::Guestfs;
 use Sys::Virt;
diff --git a/podwrapper.pl.in b/podwrapper.pl.in
index b354db6..3810f72 100755
--- a/podwrapper.pl.in
+++ b/podwrapper.pl.in
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
 # podwrapper.pl
 # Copyright (C) 2010-2015 Red Hat Inc.
 # @configure_input@
diff --git a/rescue/test-virt-rescue.pl b/rescue/test-virt-rescue.pl
index 9547fd6..2253882 100755
--- a/rescue/test-virt-rescue.pl
+++ b/rescue/test-virt-rescue.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
 # libguestfs
 # Copyright (C) 2012-2015 Red Hat Inc.
 #
@@ -17,6 +17,7 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 use strict;
+use warnings;
 
 my $progname = $0;
 $progname =~ s{.*/}{};
diff --git a/resize/test-virt-resize.pl b/resize/test-virt-resize.pl
index be9c9b4..1923398 100755
--- a/resize/test-virt-resize.pl
+++ b/resize/test-virt-resize.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
 # Copyright (C) 2010-2015 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
diff --git a/tests/bigdirs/test-big-dirs.pl b/tests/bigdirs/test-big-dirs.pl
index 47f0760..40038b7 100755
--- a/tests/bigdirs/test-big-dirs.pl
+++ b/tests/bigdirs/test-big-dirs.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 # Copyright (C) 2012 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
diff --git a/tests/btrfs/test-btrfs-misc.pl b/tests/btrfs/test-btrfs-misc.pl
index 0a8e942..cfa9cbb 100755
--- a/tests/btrfs/test-btrfs-misc.pl
+++ b/tests/btrfs/test-btrfs-misc.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 # libguestfs
 # Copyright (C) 2013 Red Hat Inc.
 #
diff --git a/tests/btrfs/test-btrfs-subvolume-default.pl b/tests/btrfs/test-btrfs-subvolume-default.pl
index fd20fa2..c3d62d3 100755
--- a/tests/btrfs/test-btrfs-subvolume-default.pl
+++ b/tests/btrfs/test-btrfs-subvolume-default.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 # libguestfs
 # Copyright (C) 2012 Red Hat Inc.
 #
diff --git a/tests/daemon/test-btrfs.pl b/tests/daemon/test-btrfs.pl
index 7a0c345..302ecb9 100755
--- a/tests/daemon/test-btrfs.pl
+++ b/tests/daemon/test-btrfs.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
 # libguestfs
 # Copyright (C) 2015 Red Hat Inc.
 #
diff --git a/tests/daemon/test-daemon-start.pl b/tests/daemon/test-daemon-start.pl
index 91e008a..8cc59d9 100755
--- a/tests/daemon/test-daemon-start.pl
+++ b/tests/daemon/test-daemon-start.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
 # libguestfs
 # Copyright (C) 2015 Red Hat Inc.
 #
diff --git a/tests/discard/test-blkdiscard.pl b/tests/discard/test-blkdiscard.pl
index e080350..9f136ec 100755
--- a/tests/discard/test-blkdiscard.pl
+++ b/tests/discard/test-blkdiscard.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 # Copyright (C) 2014 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
diff --git a/tests/discard/test-discard.pl b/tests/discard/test-discard.pl
index dbcf6a5..0253a9d 100755
--- a/tests/discard/test-discard.pl
+++ b/tests/discard/test-discard.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 # Copyright (C) 2014 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
diff --git a/tests/discard/test-fstrim.pl b/tests/discard/test-fstrim.pl
index cbd28bf..88feb06 100755
--- a/tests/discard/test-fstrim.pl
+++ b/tests/discard/test-fstrim.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 # Copyright (C) 2014 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
diff --git a/tests/disk-labels/test-disk-labels.pl b/tests/disk-labels/test-disk-labels.pl
index a74e300..17db5e1 100755
--- a/tests/disk-labels/test-disk-labels.pl
+++ b/tests/disk-labels/test-disk-labels.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 # Copyright (C) 2012 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
diff --git a/tests/disks/test-max-disks.pl b/tests/disks/test-max-disks.pl
index 9561b6b..11d4651 100755
--- a/tests/disks/test-max-disks.pl
+++ b/tests/disks/test-max-disks.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 # Copyright (C) 2012 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
diff --git a/tests/events/test-console-debug.pl b/tests/events/test-console-debug.pl
index eb6a774..777a059 100755
--- a/tests/events/test-console-debug.pl
+++ b/tests/events/test-console-debug.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 # Copyright (C) 2013 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
diff --git a/tests/fuzz/fuzz-inspection.pl b/tests/fuzz/fuzz-inspection.pl
index 9fcd98e..805558d 100755
--- a/tests/fuzz/fuzz-inspection.pl
+++ b/tests/fuzz/fuzz-inspection.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
 # Fuzz-test libguestfs inspection.
 # Copyright (C) 2013 Red Hat Inc.
 #
diff --git a/tests/guests/guest-aux/make-fedora-img.pl b/tests/guests/guest-aux/make-fedora-img.pl
index eae11d6..bd98605 100755
--- a/tests/guests/guest-aux/make-fedora-img.pl
+++ b/tests/guests/guest-aux/make-fedora-img.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 # libguestfs
 # Copyright (C) 2010-2015 Red Hat Inc.
 #
diff --git a/tests/guests/guest-aux/make-guests-all-good.pl b/tests/guests/guest-aux/make-guests-all-good.pl
index aafcc8e..ab6451a 100755
--- a/tests/guests/guest-aux/make-guests-all-good.pl
+++ b/tests/guests/guest-aux/make-guests-all-good.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 # libguestfs
 # Copyright (C) 2013 Red Hat Inc.
 #
diff --git a/tests/hotplug/test-hot-add.pl b/tests/hotplug/test-hot-add.pl
index 034cff4..18ff7c4 100755
--- a/tests/hotplug/test-hot-add.pl
+++ b/tests/hotplug/test-hot-add.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 # Copyright (C) 2012 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
diff --git a/tests/hotplug/test-hot-remove.pl b/tests/hotplug/test-hot-remove.pl
index 087399d..3e7cf72 100755
--- a/tests/hotplug/test-hot-remove.pl
+++ b/tests/hotplug/test-hot-remove.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 # Copyright (C) 2012 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
diff --git a/tests/hotplug/test-hotplug-repeated.pl b/tests/hotplug/test-hotplug-repeated.pl
index 306bceb..142f445 100755
--- a/tests/hotplug/test-hotplug-repeated.pl
+++ b/tests/hotplug/test-hotplug-repeated.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 # Copyright (C) 2012 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
diff --git a/tests/journal/test-journal.pl b/tests/journal/test-journal.pl
index 38950f9..6d8675b 100755
--- a/tests/journal/test-journal.pl
+++ b/tests/journal/test-journal.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 # libguestfs
 # Copyright (C) 2013 Red Hat Inc.
 #
diff --git a/tests/lvm/test-lvm-mapping.pl b/tests/lvm/test-lvm-mapping.pl
index 8353333..748d0e2 100755
--- a/tests/lvm/test-lvm-mapping.pl
+++ b/tests/lvm/test-lvm-mapping.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 # Copyright (C) 2010 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
diff --git a/tests/nbd/test-nbd.pl b/tests/nbd/test-nbd.pl
index 6353b25..0ad299c 100755
--- a/tests/nbd/test-nbd.pl
+++ b/tests/nbd/test-nbd.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 # Copyright (C) 2013 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
diff --git a/tests/protocol/test-launch-race.pl b/tests/protocol/test-launch-race.pl
index f933bfe..fadfdbf 100755
--- a/tests/protocol/test-launch-race.pl
+++ b/tests/protocol/test-launch-race.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 # Copyright (C) 2010 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
diff --git a/tests/regressions/test-noexec-stack.pl b/tests/regressions/test-noexec-stack.pl
index 68bbb0b..a2741b9 100755
--- a/tests/regressions/test-noexec-stack.pl
+++ b/tests/regressions/test-noexec-stack.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 # Copyright (C) 2009 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
diff --git a/tests/selinux/run-test.pl b/tests/selinux/run-test.pl
index 89846ae..f0f241f 100755
--- a/tests/selinux/run-test.pl
+++ b/tests/selinux/run-test.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 # Copyright (C) 2012 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
diff --git a/tests/syslinux/test-syslinux.pl b/tests/syslinux/test-syslinux.pl
index cea0e54..54d23c1 100755
--- a/tests/syslinux/test-syslinux.pl
+++ b/tests/syslinux/test-syslinux.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 # Copyright (C) 2013 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
diff --git a/tests/tmpdirs/test-tmpdirs.pl b/tests/tmpdirs/test-tmpdirs.pl
index a9acd8e..90aa31e 100755
--- a/tests/tmpdirs/test-tmpdirs.pl
+++ b/tests/tmpdirs/test-tmpdirs.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 # Copyright (C) 2012 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
diff --git a/tests/xfs/test-xfs-misc.pl b/tests/xfs/test-xfs-misc.pl
index 1d09474..f60d6f7 100755
--- a/tests/xfs/test-xfs-misc.pl
+++ b/tests/xfs/test-xfs-misc.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 # libguestfs
 # Copyright (C) 2013 Red Hat Inc.
 #
diff --git a/tests/xml/rhbz701814.pl b/tests/xml/rhbz701814.pl
index 01fa128..aad898f 100755
--- a/tests/xml/rhbz701814.pl
+++ b/tests/xml/rhbz701814.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
 # Copyright (C) 2012 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
@@ -19,6 +19,7 @@
 # https://bugzilla.redhat.com/show_bug.cgi?id=701814
 
 use strict;
+use warnings;
 
 use Sys::Guestfs;
 
diff --git a/tools/virt-list-filesystems b/tools/virt-list-filesystems
index 62e862b..a4d92ff 100755
--- a/tools/virt-list-filesystems
+++ b/tools/virt-list-filesystems
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
 # virt-list-filesystems
 # Copyright (C) 2009-2015 Red Hat Inc.
 #
diff --git a/tools/virt-list-partitions b/tools/virt-list-partitions
index 5579840..b9cbfdd 100755
--- a/tools/virt-list-partitions
+++ b/tools/virt-list-partitions
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
 # virt-list-partitions
 # Copyright (C) 2010 Red Hat Inc.
 #
diff --git a/tools/virt-tar b/tools/virt-tar
index a4d88a4..7ac9d95 100755
--- a/tools/virt-tar
+++ b/tools/virt-tar
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
 # virt-tar
 # Copyright (C) 2009-2015 Red Hat Inc.
 #
diff --git a/tools/virt-win-reg b/tools/virt-win-reg
index f4277e8..57188c8 100755
--- a/tools/virt-win-reg
+++ b/tools/virt-win-reg
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
 # virt-win-reg
 # Copyright (C) 2010 Red Hat Inc.
 #
-- 
2.1.0




More information about the Libguestfs mailing list