From d3adc445d67a09c96d24338efacd46c484034098 Mon Sep 17 00:00:00 2001 From: "docelic@crystallabs.io" Date: Sun, 5 May 2019 08:14:17 +0000 Subject: [PATCH] Support arrays/hashes in 'env' (WIP) - 'env' now prints 'attributes' array - 'env' output now supports any data type, not just strings - option --attributes on command line properly overrides config values The remaining thing to do is to support 'setenv' to work with non-strings too. FossilOrigin-Name: 49c1455637cbce37e0b68a4e7c7286e51f2b6401a98e11f630db3c88f737821a --- shelldap | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/shelldap b/shelldap index 5a62c0c..9de96b5 100755 --- a/shelldap +++ b/shelldap @@ -624,7 +624,7 @@ sub init $self->{'editor'} = $conf->{'editor'} || $ENV{'EDITOR'} || 'vi'; $self->{'pager'} = $conf->{'pager'} || $ENV{'PAGER'} || 'less'; - $self->{'env'} = [ qw/ debug cacheage timeout / ]; + $self->{'env'} = [ qw/ debug cacheage timeout attributes / ]; # let autocomplete work with the '=' character my $term = $self->term(); @@ -2075,11 +2075,8 @@ sub run_env { my $self = shift; - foreach ( sort @{ $self->{'env'} } ) { - print "$_: "; - print $conf->{$_} ? $conf->{$_} : 0; - print "\n" - } + print YAML::Syck::Dump( { map { $_, $conf->{$_}} sort @{ $self->{'env'}} } ); + print "\n" } @@ -2659,7 +2656,7 @@ Getopt::Long::GetOptions( 'binddn|D=s', 'basedn|b=s', 'cacheage=i', - 'attributes=s@', + 'cmdline_attributes|attributes=s@', 'paginate=i', 'promptpass|W', 'timeout=i', @@ -2696,6 +2693,11 @@ $conf->{'cacheage'} ||= 300; $conf->{'timeout'} ||= 10; $conf->{'attributes'} ||= ['*']; +# Allow command line option --attributes to override settings from +# config file. +if($conf->{'cmdline_attributes'}) { + $conf->{'attributes'} = $conf->{'cmdline_attributes'} +} # create and enter shell loop while also handling Ctrl+C correctly. my $shell = LDAP::Shell->new;