+ else
+ strings=( "$@" )
+ fi
+
+ if ! $new_file; then
+ if [[ ! -r $file ]]; then
+ echo "appendu error: cannot read or write $file"
+ return 1
+ fi
+ if [[ ! -w $file ]]; then
+ echo "appendu error: cannot read or write $file"
+ return 1
+ fi
+ # fix files with no newline at the end.
+ # the following command won't work right on them otherwise.
+ # e = run script, $a\ means append following text, but there is none,
+ # so sed only does what it always does when it was supposed to modify a file,
+ # which is append a newline if there was none.
+ sed -ie '$a\' "$file"
+ # command substitution removes any trailing newlines, so we have to add
+ # a non-newline ending, we randomly chose "b", then remove it.
+ local content=$(cat "$file"; echo b)
+ content=${content%b}