X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=cedit;h=9e0b831f848d9600c4a61415783bb0881ee9f409;hb=HEAD;hp=1cfa5803c08cdb13945b8ae81fa882f747bcfc89;hpb=bc0f839e6674afc8d0d5ffdc27fbe2733161d0b6;p=cedit diff --git a/cedit b/cedit index 1cfa580..9e0b831 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. @@ -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 ;;