#!/bin/bash # define parseline() in the sourcing script linefeeder() { for arg in "$@"; do case "$1" in -) # treat - as input stream break;; -*) # Ignore options for now shift;; esac done local file= local line= local args=("$@") # Use standard input if no files are present [ $# -eq 0 ] && args[0]="/dev/stdin" for file in "${args[@]}"; do [ "$file" == "-" ] && file="/dev/stdin" while IFS='' read -r line; do parseline "$line" done <"${file}" # If last line in a file has no newline, read ends but still populates $line [[ $line ]] && parseline "$line" done }