iankelling.org
/
git
/
cedit
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
3e93da3
)
nonzero result on modification
author
Ian Kelling
<ian@iankelling.org>
Thu, 27 Oct 2016 06:13:38 +0000
(23:13 -0700)
committer
Ian Kelling
<ian@iankelling.org>
Thu, 27 Oct 2016 06:15:46 +0000
(23:15 -0700)
cedit
patch
|
blob
|
history
diff --git
a/cedit
b/cedit
index 629fe01b1e01db5baabbed83a317206dca5ef2bb..e6d128d291ad58af7c630dd5f52e151586937859 100755
(executable)
--- a/
cedit
+++ b/
cedit
@@
-17,6
+17,9
@@
cedit() {
local help="Usage: [-h|--help ] [-v] [SECTION_NAME] FILE
Create/modify a section in a config file
local help="Usage: [-h|--help ] [-v] [SECTION_NAME] FILE
Create/modify a section in a config file
+Returns 1 if the file is modified by this command, 2 or higher
+for other problems.
+
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.
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.
@@
-47,14
+50,14
@@
section. cedit is short for config edit.
if [[ ! -e $file_dir ]]; then
if ! mkdir -p $file_dir; then
s=sudo
if [[ ! -e $file_dir ]]; then
if ! mkdir -p $file_dir; then
s=sudo
- $s mkdir -p $file_dir || return
1
+ $s mkdir -p $file_dir || return
2
fi
fi
if [[ ! -e $file ]]; then
exists=false
if ! $s touch $file; then
s=sudo
fi
fi
if [[ ! -e $file ]]; then
exists=false
if ! $s touch $file; then
s=sudo
- $s touch $file || return
1
+ $s touch $file || return
2
fi
fi
fi
fi
@@
-88,7
+91,7
@@
section. cedit is short for config edit.
fi
if ! $exists; then
fi
if ! $exists; then
- ret=
0
+ ret=
1
if $verbose; then
echo "New file $file:"
cat "$file"
if $verbose; then
echo "New file $file:"
cat "$file"
@@
-101,17
+104,18
@@
section. cedit is short for config edit.
echo "No changes made to $file"
fi
else
echo "No changes made to $file"
fi
else
-
echo "backup of original at $temp"
echo diff -u "$temp" "$file":
echo "$diff"
fi
else
echo "backup of original at $temp"
echo diff -u "$temp" "$file":
echo "$diff"
fi
else
+ # for systems like openwrt which don't have diff
diff=$(cmp "$temp" "$file")
diff=$(cmp "$temp" "$file")
+ ret=$?
if $verbose; then
echo "$diff"
fi
fi
if $verbose; then
echo "$diff"
fi
fi
- return
0
+ return
$ret
}
cedit "$@"
}
cedit "$@"