only-if-file-present

This commit is contained in:
stephan 2022-07-31 19:30:42 +02:00
parent a379bfc742
commit 55d6e21a1d
4 changed files with 6 additions and 3 deletions

View file

@ -38,7 +38,7 @@ if [ -z "$state_is" ]; then
echo "touch $file" echo "touch $file"
else else
# only bark if the file should exists # only bark if the file should exists
if [ -f "$__object/parameter/ifexists" ]; then if [ -f "$__object/parameter/only-if-file-present" ]; then
exit 0 exit 0
fi fi
printf 'The file "%s" is missing. Please create it before using %s on it.\n' "$file" "${__type##*/}" >&2 printf 'The file "%s" is missing. Please create it before using %s on it.\n' "$file" "${__type##*/}" >&2

View file

@ -31,8 +31,9 @@ file
If supplied, use this as the destination file. If supplied, use this as the destination file.
Otherwise the object_id is used. Otherwise the object_id is used.
ifexists only-if-file-present
Only apply the line if the file exists. Only apply the line if the file exists. This can be used to prevent
adding the line to a non-existent file.
line line
Specifies the line which should be absent or present. Specifies the line which should be absent or present.

View file

@ -0,0 +1,2 @@
create
only-if-file-present