[__line] Produce error when file does not exist
This commit is contained in:
parent
51b1b11cc2
commit
5a9a1ba57f
2 changed files with 12 additions and 10 deletions
|
@ -25,10 +25,7 @@ else
|
||||||
file="/$__object_id"
|
file="/$__object_id"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f "$file" ]; then
|
[ -f "$file" ] || exit 0
|
||||||
echo "file_missing"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -f "$__object/parameter/before" ]; then
|
if [ -f "$__object/parameter/before" ]; then
|
||||||
position="before"
|
position="before"
|
||||||
|
|
|
@ -24,9 +24,20 @@ if [ -f "$__object/parameter/before" ] && [ -f "$__object/parameter/after" ]; th
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -f "$__object/parameter/file" ]; then
|
||||||
|
file="$(cat "$__object/parameter/file")"
|
||||||
|
else
|
||||||
|
file="/$__object_id"
|
||||||
|
fi
|
||||||
|
|
||||||
state_should="$(cat "$__object/parameter/state")"
|
state_should="$(cat "$__object/parameter/state")"
|
||||||
state_is="$(cat "$__object/explorer/state")"
|
state_is="$(cat "$__object/explorer/state")"
|
||||||
|
|
||||||
|
if [ -z "$state_is" ]; then
|
||||||
|
printf 'The file "%s" is missing. Please create it before using %s on it.\n' "$file" "${__type##*/}" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$state_should" = "$state_is" ]; then
|
if [ "$state_should" = "$state_is" ]; then
|
||||||
# nothing to do
|
# nothing to do
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -47,12 +58,6 @@ else
|
||||||
needle="line"
|
needle="line"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f "$__object/parameter/file" ]; then
|
|
||||||
file="$(cat "$__object/parameter/file")"
|
|
||||||
else
|
|
||||||
file="/$__object_id"
|
|
||||||
fi
|
|
||||||
|
|
||||||
add=0
|
add=0
|
||||||
remove=0
|
remove=0
|
||||||
case "$state_should" in
|
case "$state_should" in
|
||||||
|
|
Loading…
Reference in a new issue