diff --git a/shelldap b/shelldap index 7cb87a5..e0afa80 100755 --- a/shelldap +++ b/shelldap @@ -1511,6 +1511,7 @@ sub run_edit if ( $hash_orig eq $self->chksum($self->{'ldif_fname'}) ) { print "Entry not modified.\n"; unlink $self->{'ldif_fname'}; + $self->{'edit_again'} = undef; return; } @@ -1523,6 +1524,7 @@ sub run_edit } else { unlink $self->{'ldif_fname'}; + $self->{'edit_again'} = undef; return; } } @@ -1554,7 +1556,7 @@ sub run_edit my $diff_bit = $diff->Diff(); my %seen_attr; - # attr removals + # attr removal hunk # if ( $diff_bit == 1 ) { foreach ( $diff->Items(1) ) { @@ -1564,7 +1566,7 @@ sub run_edit } } - # attr insertions + # attr insertion hunk # if ( $diff_bit == 2 ) { foreach ( $diff->Items(2) ) { @@ -1574,9 +1576,12 @@ sub run_edit } } - # attr change + # attr change hunk # if ( $diff_bit == 3 ) { + + # modification to existing line + # foreach ( $diff->Items(2) ) { my ( $attr, $val ) = $parse->( $_ ) or next; $self->debug("MODIFY: $_"); @@ -1608,6 +1613,15 @@ sub run_edit $e->replace( $attr => \@new_vals ); } } + + # deletion within the same hunk + # + foreach ( $diff->Items(1) ) { + my ( $attr, $val ) = $parse->( $_ ) or next; + next if $seen_attr{ $attr }; + $self->debug("DELETE: $_"); + $e->delete( $attr => [ $val ] ); + } } } @@ -2143,7 +2157,7 @@ use strict; use warnings; $0 = 'shelldap'; -my $VERSION = '1.0.0'; +my $VERSION = '1.0.1'; use Getopt::Long; use YAML::Syck;