Alter the default wrap width for LDIF to expand to the terminal size,
with an optional rc file override.
--- a/shelldap Fri Mar 15 10:02:18 2013 -0700
+++ b/shelldap Fri Mar 15 10:02:19 2013 -0700
@@ -564,17 +564,28 @@
my $self = shift;
my $use_temp = shift;
+ # find the terminal width
+ #
+ my $wrap = $conf->{'wrap'};
+ eval {
+ my $rows;
+ my $term = Term::ReadLine->new( 1 );
+ ( $rows, $wrap ) = $term->get_screen_size() unless $wrap;
+ };
+ $wrap ||= 78;
+
# create tmpfile and link ldif object with it
+ #
if ( $use_temp ) {
my ( undef, $fname ) =
File::Temp::tempfile( 'shelldap_XXXXXXXX', DIR => '/tmp', UNLINK => 1 );
- $self->{'ldif'} = Net::LDAP::LDIF->new( $fname, 'w', sort => 1 );
+ $self->{'ldif'} = Net::LDAP::LDIF->new( $fname, 'w', sort => 1, wrap => $wrap );
$self->{'ldif_fname'} = $fname;
}
# ldif -> stdout
else {
- $self->{'ldif'} = Net::LDAP::LDIF->new( \*STDOUT, 'w', sort => 1 );
+ $self->{'ldif'} = Net::LDAP::LDIF->new( \*STDOUT, 'w', sort => 1, wrap => $wrap );
}
return $self->{'ldif'};