From 6a87cd1f0f0106d140352f7c4299cb88bf4fcc09 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Sun, 24 Sep 2017 12:12:07 +0200 Subject: [PATCH] Fix saving config file --- scripts/patrix | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/patrix b/scripts/patrix index e7c4c89..a61f567 100644 --- a/scripts/patrix +++ b/scripts/patrix @@ -496,11 +496,13 @@ sub del_room_alias { # Write settings in a config file sub setup { - my $cfg = Config::Simple->new($opt->{conf}); + $opt->{conf} //= File::HomeDir->my_home . "/.patrixrc"; + my $cfg = Config::Simple->new(syntax => 'ini'); foreach my $param (qw(access_token server room)){ $cfg->param($param, $opt->{$param}) if ($opt->{$param}); } - $cfg->save; + debug("Writing config file $opt->{conf}"); + $cfg->save($opt->{conf}); } # If we ask for a new access token, then we must login, and ignore any @@ -537,7 +539,8 @@ set_defaults(); # Should we logout at the end ? Only if we used login and pass # If we used an access_token, we don't want it to be invalidated -my $must_logout = ($opt->{access_token} || $opt->{action} eq 'get-access-token') ? 0 : 1; +my $must_logout = ($opt->{access_token} || ($opt->{action} eq 'get-access-token' || + $opt->{action} eq 'setup')) ? 0 : 1; # If we don't have an access token, we must get one now if (!$opt->{access_token}){