From 97e5ceaf2d7d3fec58fcd6b0004f221b19783620 Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Wed, 24 Apr 2024 15:34:05 -0400 Subject: [PATCH 1/2] minor docs update --- README | 16 +++++++++------- cedit | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/README b/README index 88bd451..0287269 100644 --- a/README +++ b/README @@ -1,12 +1,14 @@ -The following is the GNU All-permissive License as recommended in - +# The following is the GNU All-permissive License as recommended in +# -Copyright (C) 2024 Ian Kelling +# Copyright (C) 2024 Ian Kelling -Copying and distribution of this file, with or without modification, -are permitted in any medium without royalty provided the copyright -notice and this notice are preserved. This file is offered as-is, -without any warranty. +# Copying and distribution of this file, with or without modification, +# are permitted in any medium without royalty provided the copyright +# notice and this notice are preserved. This file is offered as-is, +# without any warranty. + +Create/modify a comment-delimited section in a config file The main documentation is availiable via --help and near the top of the bash script file next to this file. diff --git a/cedit b/cedit index 1cfa580..e47afa5 100755 --- a/cedit +++ b/cedit @@ -22,7 +22,7 @@ cedit() { local help="Usage: [-h|--help ] [-v] [SECTION_NAME] FILE -Create/modify a section in a config file +Create/modify a comment-delimited section in a config file Returns 1 if the file is modified by this command, 2 or higher for other problems. -- 2.30.2 From 26a1849cd31a766d6fbe04ed223b88237543908a Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Mon, 20 May 2024 18:07:58 -0400 Subject: [PATCH 2/2] add option to not alter exit status on modification --- cedit | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/cedit b/cedit index e47afa5..9e0b831 100755 --- a/cedit +++ b/cedit @@ -31,10 +31,11 @@ The section is #comment delimited. Reads STDIN for the contents of the section. Without SECTION_NAME, it acts on a global unnamed section. cedit is short for config edit. --q Quiet +-b Keep backup file +-e Exit 0 on modified file. -s Silent. Quiet and exit 0 on modified file. +-q Quiet -v Verbose --b Keep backup file -h|--help Help" local s diff name init file_dir exists verbose backup quiet silent file_dir="$(dirname "$file")" @@ -43,12 +44,14 @@ section. cedit is short for config edit. backup=false quiet=false silent=false + exit_status=true case $1 in -b) backup=true; shift ;; - -v) verbose=true; shift ;; + -e) exit_status=false; shift ;; + -s) quiet=true; silent=true; exit_status=false; shift ;; -q) quiet=true; shift ;; - -s) quiet=true; silent=true; shift ;; + -v) verbose=true; shift ;; -h|--help) echo "$help"; return ;; esac @@ -153,7 +156,7 @@ section. cedit is short for config edit. if ! $backup && $exists; then rm -r "$temp" fi - if $silent; then + if ! $exit_status; then case $ret in 0|1) return 0 ;; *) return $ret ;; -- 2.30.2