From b0337f001bee1f3791cb87505b1330c9bf83e2be Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sun, 27 Jul 2014 20:07:32 +0200 Subject: scripts: Use //= instead of ||= when appropriate Replace only safe usages, i.e. those that fallback on initialization values that evaluate to false anyway. Or when the API is explicit about the variable being undefined. --- scripts/Dpkg/Compression/Process.pm | 2 +- scripts/Dpkg/IPC.pm | 4 ++-- scripts/Dpkg/Shlibs/Objdump.pm | 2 +- scripts/Dpkg/Source/Archive.pm | 8 ++++---- scripts/Dpkg/Source/Package.pm | 4 ++-- scripts/Dpkg/Source/Package/V1.pm | 8 ++++---- scripts/Dpkg/Source/Patch.pm | 10 +++++----- scripts/Dpkg/Substvars.pm | 2 +- scripts/changelog/debian.pl | 4 ++-- scripts/dpkg-buildpackage.pl | 2 +- scripts/dpkg-genchanges.pl | 2 +- 11 files changed, 24 insertions(+), 24 deletions(-) (limited to 'scripts') diff --git a/scripts/Dpkg/Compression/Process.pm b/scripts/Dpkg/Compression/Process.pm index 03d6f276d..8ee5a57a0 100644 --- a/scripts/Dpkg/Compression/Process.pm +++ b/scripts/Dpkg/Compression/Process.pm @@ -190,7 +190,7 @@ it for you. sub wait_end_process { my ($self, %opts) = @_; - $opts{cmdline} ||= $self->{cmdline}; + $opts{cmdline} //= $self->{cmdline}; wait_child($self->{pid}, %opts) if $self->{pid}; delete $self->{pid}; delete $self->{cmdline}; diff --git a/scripts/Dpkg/IPC.pm b/scripts/Dpkg/IPC.pm index 4f57b736b..0666304c9 100644 --- a/scripts/Dpkg/IPC.pm +++ b/scripts/Dpkg/IPC.pm @@ -184,7 +184,7 @@ sub _sanity_check_opts { sub spawn { my (%opts) = _sanity_check_opts(@_); - $opts{close_in_child} ||= []; + $opts{close_in_child} //= []; my @prog; if (ref($opts{exec}) =~ /ARRAY/) { push @prog, @{$opts{exec}}; @@ -340,7 +340,7 @@ with an error message. sub wait_child { my ($pid, %opts) = @_; - $opts{cmdline} ||= _g('child process'); + $opts{cmdline} //= _g('child process'); croak 'no PID set, cannot wait end of process' unless $pid; eval { local $SIG{ALRM} = sub { die "alarm\n" }; diff --git a/scripts/Dpkg/Shlibs/Objdump.pm b/scripts/Dpkg/Shlibs/Objdump.pm index f85fd9aba..cb0cc46ee 100644 --- a/scripts/Dpkg/Shlibs/Objdump.pm +++ b/scripts/Dpkg/Shlibs/Objdump.pm @@ -173,7 +173,7 @@ sub reset { sub analyze { my ($self, $file) = @_; - $file ||= $self->{file}; + $file //= $self->{file}; return unless $file; $self->reset; diff --git a/scripts/Dpkg/Source/Archive.pm b/scripts/Dpkg/Source/Archive.pm index 6257702b7..5deb90ee5 100644 --- a/scripts/Dpkg/Source/Archive.pm +++ b/scripts/Dpkg/Source/Archive.pm @@ -35,7 +35,7 @@ use parent qw(Dpkg::Compression::FileHandle); sub create { my ($self, %opts) = @_; - $opts{options} ||= []; + $opts{options} //= []; my %spawn_opts; # Possibly run tar from another directory if ($opts{chdir}) { @@ -99,9 +99,9 @@ sub finish { sub extract { my ($self, $dest, %opts) = @_; - $opts{options} ||= []; - $opts{in_place} ||= 0; - $opts{no_fixperms} ||= 0; + $opts{options} //= []; + $opts{in_place} //= 0; + $opts{no_fixperms} //= 0; my %spawn_opts = (wait_child => 1); # Prepare destination diff --git a/scripts/Dpkg/Source/Package.pm b/scripts/Dpkg/Source/Package.pm index 6dfef4f20..57eddd6de 100644 --- a/scripts/Dpkg/Source/Package.pm +++ b/scripts/Dpkg/Source/Package.pm @@ -212,7 +212,7 @@ sub init_options { my ($self) = @_; # Use full ignore list by default # note: this function is not called by V1 packages - $self->{options}{diff_ignore_regex} ||= $diff_ignore_default_regex; + $self->{options}{diff_ignore_regex} //= $diff_ignore_default_regex; $self->{options}{diff_ignore_regex} .= '|(?:^|/)debian/source/local-.*$'; if (defined $self->{options}{tar_ignore}) { $self->{options}{tar_ignore} = [ @tar_ignore_default_pattern ] @@ -224,7 +224,7 @@ sub init_options { 'debian/source/local-patch-header'; # Skip debianization while specific to some formats has an impact # on code common to all formats - $self->{options}{skip_debianization} ||= 0; + $self->{options}{skip_debianization} //= 0; # Set default compressor for new formats. $self->{options}{compression} //= 'xz'; diff --git a/scripts/Dpkg/Source/Package/V1.pm b/scripts/Dpkg/Source/Package/V1.pm index 70970fc11..626ef7756 100644 --- a/scripts/Dpkg/Source/Package/V1.pm +++ b/scripts/Dpkg/Source/Package/V1.pm @@ -51,10 +51,10 @@ sub init_options { } push @{$self->{options}{tar_ignore}}, 'debian/source/local-options', 'debian/source/local-patch-header'; - $self->{options}{sourcestyle} ||= 'X'; - $self->{options}{skip_debianization} ||= 0; - $self->{options}{ignore_bad_version} ||= 0; - $self->{options}{abort_on_upstream_changes} ||= 0; + $self->{options}{sourcestyle} //= 'X'; + $self->{options}{skip_debianization} //= 0; + $self->{options}{ignore_bad_version} //= 0; + $self->{options}{abort_on_upstream_changes} //= 0; # V1.0 only supports gzip compression. $self->{options}{compression} //= 'gzip'; diff --git a/scripts/Dpkg/Source/Patch.pm b/scripts/Dpkg/Source/Patch.pm index 8b5683357..ab4fb79de 100644 --- a/scripts/Dpkg/Source/Patch.pm +++ b/scripts/Dpkg/Source/Patch.pm @@ -551,9 +551,9 @@ sub apply { $opts{force_timestamp} //= 1; $opts{remove_backup} //= 1; $opts{create_dirs} //= 1; - $opts{options} ||= [ '-t', '-F', '0', '-N', '-p1', '-u', + $opts{options} //= [ '-t', '-F', '0', '-N', '-p1', '-u', '-V', 'never', '-g0', '-b', '-z', '.dpkg-orig']; - $opts{add_options} ||= []; + $opts{add_options} //= []; push @{$opts{options}}, @{$opts{add_options}}; # Check the diff and create missing directories my $analysis = $self->analyze($destdir, %opts); @@ -583,7 +583,7 @@ sub apply { # and remove .dpkg-orig files my @files = keys %{$analysis->{filepatched}}; my $now = $opts{timestamp}; - $now ||= fs_time($files[0]) if $opts{force_timestamp} && scalar @files; + $now //= fs_time($files[0]) if $opts{force_timestamp} && scalar @files; foreach my $fn (@files) { if ($opts{force_timestamp}) { utime($now, $now, $fn) or $! == ENOENT @@ -602,9 +602,9 @@ sub check_apply { my ($self, $destdir, %opts) = @_; # Set default values to options $opts{create_dirs} //= 1; - $opts{options} ||= [ '--dry-run', '-s', '-t', '-F', '0', '-N', '-p1', '-u', + $opts{options} //= [ '--dry-run', '-s', '-t', '-F', '0', '-N', '-p1', '-u', '-V', 'never', '-g0', '-b', '-z', '.dpkg-orig']; - $opts{add_options} ||= []; + $opts{add_options} //= []; push @{$opts{options}}, @{$opts{add_options}}; # Check the diff and create missing directories my $analysis = $self->analyze($destdir, %opts); diff --git a/scripts/Dpkg/Substvars.pm b/scripts/Dpkg/Substvars.pm index fe7a640be..2a6aace39 100644 --- a/scripts/Dpkg/Substvars.pm +++ b/scripts/Dpkg/Substvars.pm @@ -223,7 +223,7 @@ sub set_version_substvars { my ($self, $sourceversion, $binaryversion) = @_; # Handle old function signature taking only one argument. - $binaryversion ||= $sourceversion; + $binaryversion //= $sourceversion; # For backwards compatibility on binNMUs that do not use the Binary-Only # field on the changelog, always fix up the source version. diff --git a/scripts/changelog/debian.pl b/scripts/changelog/debian.pl index 4c9f83d4a..95f72f53b 100755 --- a/scripts/changelog/debian.pl +++ b/scripts/changelog/debian.pl @@ -119,8 +119,8 @@ if (@ARGV) { $file = $ARGV[0]; } -$file ||= $default_file; -$label ||= $file; +$file //= $default_file; +$label //= $file; unless (defined($since) or defined($until) or defined($from) or defined($to) or defined($offset) or defined($count) or defined($all)) diff --git a/scripts/dpkg-buildpackage.pl b/scripts/dpkg-buildpackage.pl index 0e794e5ee..ba0f3fe41 100755 --- a/scripts/dpkg-buildpackage.pl +++ b/scripts/dpkg-buildpackage.pl @@ -362,7 +362,7 @@ if (defined $parallel) { chomp $parallel; } $parallel = $build_opts->get('parallel') if $build_opts->has('parallel'); - $ENV{MAKEFLAGS} ||= ''; + $ENV{MAKEFLAGS} //= ''; $ENV{MAKEFLAGS} .= " -j$parallel"; $build_opts->set('parallel', $parallel); $build_opts->export(); diff --git a/scripts/dpkg-genchanges.pl b/scripts/dpkg-genchanges.pl index 19e40fef4..429094c45 100755 --- a/scripts/dpkg-genchanges.pl +++ b/scripts/dpkg-genchanges.pl @@ -249,7 +249,7 @@ if (not is_sourceonly) { foreach my $file ($dist->get_files()) { if (defined $file->{package} && $file->{package_type} =~ m/^u?deb$/) { - $p2f{$file->{package}} ||= []; + $p2f{$file->{package}} //= []; push @{$p2f{$file->{package}}}, $file->{filename}; } -- cgit v1.2.3