From 0dd0716c761e328292bf8aac1b15edbdc4f73d2e Mon Sep 17 00:00:00 2001 From: Einhard Leichtfuß Date: Tue, 25 Dec 2018 17:04:47 +0100 Subject: Globally use the same (default_)user_config_dir Also, - Fix issues with doubled slashes in man pages (in configure.ac). - Update some copyright years. --- Makefile.in | 2 +- TODO | 3 --- bash_completion.in | 19 ++++++++----------- configure | 33 ++++++++++++++++++--------------- configure.ac | 29 ++++++++++++++--------------- ctct.in | 3 ++- ctct_config.5.in | 4 ++-- ctct_config.in | 1 + 8 files changed, 46 insertions(+), 48 deletions(-) diff --git a/Makefile.in b/Makefile.in index d3f205f..e18bb97 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,6 +1,6 @@ # Makefile for ctct # -# Copyright 2015, 2016 Einhard Leichtfuß +# Copyright 2015, 2016, 2018 Einhard Leichtfuß # # This file is part of ctct. # diff --git a/TODO b/TODO index 01f78b8..ca9ada7 100644 --- a/TODO +++ b/TODO @@ -8,9 +8,6 @@ TODO file for ctct * [consider] Require at least one argument for --search-by-*. [CONFIGURE SCRIPT] -* Take care of some_dir=/ (man page). -* Fully expand all variables found outside Makefile.in, like is already done - for sysconfdir_expanded. [FEATURES] * [consider] Allow for directories with special meaning (e.g. pictures/). diff --git a/bash_completion.in b/bash_completion.in index a8fa219..eb6eb10 100644 --- a/bash_completion.in +++ b/bash_completion.in @@ -2,7 +2,7 @@ # # bash completion script for ctct # -# Copyright 2015 - 2017 Einhard Leichtfuß +# Copyright 2015 - 2018 Einhard Leichtfuß # # This file is part of ctct. # @@ -23,21 +23,18 @@ _ctct() { ## DEFAULT SETTINGS: + local sysconfdir="@sysconfdir_expanded@" + local user_config_file="@default_user_config_file@" local datadir="@default_datadir@" - local system_config_dir="@default_confdir@" - local user_config_dir="@default_user_config_dir@" local temp ## USER SETTINGS: - temp=$( - test -f "$system_config_dir/config.sh" \ - && source "$system_config_dir/config.sh" - test -f "$user_config_dir/config.sh" \ - && source "$user_config_dir/config.sh" - echo "$datadir" - ) - test -n "$temp" && datadir="$temp" + test -f "$sysconfdir/ctct_config" \ + && source "$sysconfdir/ctct_config" + test -f "$user_config_file" \ + && source "$user_config_file" + echo "$datadir" local cur action opts typeset -i i diff --git a/configure b/configure index 35c1039..6f83b0a 100755 --- a/configure +++ b/configure @@ -593,6 +593,7 @@ default_output_program default_input_program default_fallback_editor default_datadir +default_user_config_file sysconfdir_expanded bash_completion_dir ret_error @@ -1734,7 +1735,7 @@ test -z "$bash_completion_dir" \ # Use a function to allow for local variables. -fun() { +expand_sysconfdir() { local prefix="$prefix" local TARGET="$PACKAGE_NAME" local next @@ -1742,9 +1743,6 @@ fun() { # If $prefix is unset by the user, set it to autoconf's default value: test "$prefix" = NONE && prefix=/usr/local - # Prevent //. - test "$prefix" = / && prefix='' - sysconfdir_expanded="$sysconfdir" # Expand $sysconfdir recursively (notably including $prefix): @@ -1754,7 +1752,15 @@ fun() { do sysconfdir_expanded="$next" done -}; fun + + # Prevent //. + sysconfdir_expanded="${sysconfdir_expanded//\/\//\/}" + test "$sysconfdir_expanded" = / && sysconfdir_expanded='' +}; expand_sysconfdir + + +default_user_config_file='$HOME/.config/ctct_config' + @@ -1764,24 +1770,19 @@ test -z "$default_datadir" && default_datadir='$HOME/.ctct' test -z "$default_fallback_editor" && default_fallback_editor=vi -test -z "$default_input_program" \ - && default_input_program='cat' +test -z "$default_input_program" && default_input_program='cat' -test -z "$default_output_program" \ - && default_output_program='cat' +test -z "$default_output_program" && default_output_program='cat' -test -z "$default_visual_program" \ - && default_visual_program='cat' +test -z "$default_visual_program" && default_visual_program='cat' -test -z "$default_confirm_deletion" \ - && default_confirm_deletion=true +test -z "$default_confirm_deletion" && default_confirm_deletion=true -test -z "$default_confirm_default_yes" \ - && default_confirm_default_yes=false +test -z "$default_confirm_default_yes" && default_confirm_default_yes=false cat >confcache <<\_ACEOF @@ -2949,3 +2950,5 @@ if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi + +# vi: ts=2 sw=2 diff --git a/configure.ac b/configure.ac index dd45df4..3dd2988 100644 --- a/configure.ac +++ b/configure.ac @@ -46,7 +46,7 @@ test -z "$bash_completion_dir" \ AC_SUBST([sysconfdir_expanded]) # Use a function to allow for local variables. -fun() { +expand_sysconfdir() { local prefix="$prefix" local TARGET="$PACKAGE_NAME" local next @@ -54,9 +54,6 @@ fun() { # If $prefix is unset by the user, set it to autoconf's default value: test "$prefix" = NONE && prefix=/usr/local - # Prevent //. - test "$prefix" = / && prefix='' - sysconfdir_expanded="$sysconfdir" # Expand $sysconfdir recursively (notably including $prefix): @@ -66,7 +63,14 @@ fun() { do sysconfdir_expanded="$next" done -}; fun + + # Prevent //. + sysconfdir_expanded="${sysconfdir_expanded//\/\//\/}" + test "$sysconfdir_expanded" = / && sysconfdir_expanded='' +}; expand_sysconfdir + + +AC_SUBST([default_user_config_file], ['$HOME/.config/ctct_config']) AC_ARG_VAR([default_datadir], ['directory to store contact data in']) @@ -77,28 +81,23 @@ test -z "$default_fallback_editor" && default_fallback_editor=vi AC_ARG_VAR([default_input_program], ['the program that newly created or edited contact files get passed to on stdin']) -test -z "$default_input_program" \ - && default_input_program='cat' +test -z "$default_input_program" && default_input_program='cat' AC_ARG_VAR([default_output_program], ['the program that gets passed the contact files on stdin']) -test -z "$default_output_program" \ - && default_output_program='cat' +test -z "$default_output_program" && default_output_program='cat' AC_ARG_VAR([default_visual_program], ['the program that is used to display the data']) -test -z "$default_visual_program" \ - && default_visual_program='cat' +test -z "$default_visual_program" && default_visual_program='cat' AC_ARG_VAR([default_confirm_deletion], ['whether to ask for confirmation upon deletion of a contact']) -test -z "$default_confirm_deletion" \ - && default_confirm_deletion=true +test -z "$default_confirm_deletion" && default_confirm_deletion=true AC_ARG_VAR([default_confirm_default_yes], ['whether to consider "yes" as answer upon a not answered confirmation']) -test -z "$default_confirm_default_yes" \ - && default_confirm_default_yes=false +test -z "$default_confirm_default_yes" && default_confirm_default_yes=false AC_OUTPUT diff --git a/ctct.in b/ctct.in index 74a40f8..44c271a 100644 --- a/ctct.in +++ b/ctct.in @@ -20,6 +20,7 @@ ## DEFAULT SETTINGS: sysconfdir="@sysconfdir_expanded@" +user_config_file="@user_config_file@" datadir="@default_datadir@" fallback_editor="@default_fallback_editor@" default_editor= # none - use $EDITOR @@ -486,7 +487,7 @@ function check_non_existance() function print_version() { cat << EOF ctct - Version @PACKAGE_VERSION@ -Copyright 2015, 2016 Einhard Leichtfuß. +Copyright 2015 - 2018 Einhard Leichtfuß. License AGPLv3+: GNU Affero General Public License, version 3 or later - This is free software: You are free to change and redistribute it. diff --git a/ctct_config.5.in b/ctct_config.5.in index ccf146e..f29f64b 100644 --- a/ctct_config.5.in +++ b/ctct_config.5.in @@ -47,7 +47,7 @@ If set, this variable must contain the prefix or alternatively any other variable resolving to a directory below the respective home directory\. The default value is -.IR $HOME/.config/ctct_config" \. +.IR @default_user_config_file@ \. .\" .TP .B datadir @@ -179,7 +179,7 @@ file are stored by default\. System wide configuration file\. .\" .TP -.I $HOME/.config/config\.sh +.I @default_user_config_file@ Default location of the user configuration file\. .\" .TP diff --git a/ctct_config.in b/ctct_config.in index 0231725..19b1799 100644 --- a/ctct_config.in +++ b/ctct_config.in @@ -4,6 +4,7 @@ # default values are commented out # +# user_config_file="@default_user_config_file@" # datadir="@default_datadir@" # fallback_editor="@default_fallback_editor@" # default_editor= -- cgit v1.2.3