#!/bin/bash # file: gsl__edit_file # Folder: /var/lib/gsl/scripts # By echolib (XMPP: im@echolib.re) # License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 #====================================================================== # Get arguments from COMMAND (edit) # $2: FILE | conf # $3: FILE #====================================================================== edit__file_OPTIONS() { ! [[ "$1" ]] \ && gsl__invalid_option "$1" "[File]|conf|author|domain" case "$1" in conf) gsl_this_post="$gsl_file_domain_conf" ;; author) author__OPTIONS edit ;; domain) gsl_this_post="$gsl_file_db_domains" ;; *) if__gsl_post;if__file "$PWD/$1" post ;; esac gsl_post=`basename "$gsl_this_post"` if ! [[ "$EDITOR" ]];then if__command nano EDITOR=`which nano` EDITOR+=" --linenumbers" elif [[ "$EDITOR" =~ "nano" ]];then EDITOR+=" --linenumbers" fi gsl__logs_print -i -B -P \ "edit with $EDITOR" \ "$gsl_this_post" gsl_proc="edit" article__sum "$gsl_this_post" article_Hash_old=$article_Hash $EDITOR "$gsl_this_post" article__sum "$gsl_this_post" if (( $article_Hash != $article_Hash_old ));then gsl_log_infos="Changed ; Hash: $article_Hash" gsl_log_level="-w" else gsl_log_infos="Unchanged" gsl_log_level="-i" fi gsl__logs_print "$gsl_log_level" -f -e \ "$gsl_log_infos" \ "$gsl_this_post" gsl__logs_print -i -E -P \ "edit with $EDITOR" \ "$gsl_this_post" }