This functions now: - return an error when the destination is a directory - creates the destination if the destination not exist
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org --- src/functions/functions.util | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/src/functions/functions.util b/src/functions/functions.util index 381208c..dd223f9 100644 --- a/src/functions/functions.util +++ b/src/functions/functions.util @@ -179,12 +179,21 @@ fwrite() { assert isset file shift
- if [ ! -w "${file}" ]; then - log ERROR "${file}: No such file" + if [ -d "${file}" ]; then + log ERROR "${file} is a directory" return ${EXIT_ERROR} fi
- print "%s" "$@" >> ${file} 2>/dev/null + if [ -f "${file}" ]; then + if [ -w "${file}" ]; then + print "%s" "$@" >> ${file} 2>/dev/null + else + log ERROR "${file} is not writeable" + return ${EXIT_ERROR} + fi + else + print "%s" "$@" >> ${file} 2>/dev/null + fi }
make_parent_dir() {