add create and ifexists to line type
This commit is contained in:
parent
483f0c1614
commit
6243165645
2 changed files with 16 additions and 2 deletions
|
@ -34,9 +34,17 @@ state_should="$(cat "$__object/parameter/state")"
|
||||||
state_is="$(cat "$__object/explorer/state")"
|
state_is="$(cat "$__object/explorer/state")"
|
||||||
|
|
||||||
if [ -z "$state_is" ]; then
|
if [ -z "$state_is" ]; then
|
||||||
|
if [ -f "$__object/parameter/create" ]; then
|
||||||
|
echo "touch $file"
|
||||||
|
else
|
||||||
|
# only bark if the file should exists
|
||||||
|
if [ -f "$__object/parameter/ifexists" ]; then
|
||||||
|
exit 0
|
||||||
|
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
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$state_should" = "$state_is" ] || \
|
if [ "$state_should" = "$state_is" ] || \
|
||||||
{ [ "$state_should" = "present" ] && [ "$state_is" = "matching" ] ;} || \
|
{ [ "$state_should" = "present" ] && [ "$state_is" = "matching" ] ;} || \
|
||||||
|
|
|
@ -21,6 +21,9 @@ OPTIONAL PARAMETERS
|
||||||
after
|
after
|
||||||
Insert the given line after this pattern.
|
Insert the given line after this pattern.
|
||||||
|
|
||||||
|
create
|
||||||
|
It the file does not exist then create an empty file
|
||||||
|
|
||||||
before
|
before
|
||||||
Insert the given line before this pattern.
|
Insert the given line before this pattern.
|
||||||
|
|
||||||
|
@ -28,6 +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 apply the line if the file exists.
|
||||||
|
|
||||||
line
|
line
|
||||||
Specifies the line which should be absent or present.
|
Specifies the line which should be absent or present.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue