add comments, add -u to diff

This commit is contained in:
ander 2021-09-16 21:36:39 +03:00
parent cd4acde67e
commit 72ff48154c
No known key found for this signature in database
GPG Key ID: 0A2971E562D618F3
1 changed files with 6 additions and 4 deletions

View File

@ -14,6 +14,8 @@ then
script="$( cat "$__object/stdin" )" script="$( cat "$__object/stdin" )"
fi fi
# since stdin is not available in explorer, we pull file from target with explorer
file_from_target="$__object/explorer/file" file_from_target="$__object/explorer/file"
sed_cmd='sed' sed_cmd='sed'
@ -23,10 +25,10 @@ then
sed_cmd="$sed_cmd -E" sed_cmd="$sed_cmd -E"
fi fi
if echo "$script" \ # do sed dry run, diff result and if no change, then there's nothing to do
| "$sed_cmd" -f - "$file_from_target" \ # also redirect diff's output to stderr for debugging purposes
| diff "$file_from_target" - \
> /dev/null if echo "$script" | "$sed_cmd" -f - "$file_from_target" | diff -u "$file_from_target" - >&2
then then
exit 0 exit 0
fi fi