- if (( $# == 0 )); then
- unset IFS
- while read -r x; do
- strings+=( "$x" )
- done
- else
- strings=( "$@" )
- 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.
- content=$(cat "$file"; echo b) content=${content%b}
-