bash-com/read

21 lines
488 B
Plaintext
Raw Normal View History

#!/bin/bash
# (0) Get current ABS directory
ROOT=$(dirname `realpath $0`);
# (1) Check arguments
test $# -lt 1 && echo "ERR: Missing arguments (name)" && exit 1;
# (2) Manage optional argument #
FLUSH=1;
test $# -ge 2 -a "$2" = "-" && FLUSH=0;
# (2) load configuration file
test -f $ROOT/config/$1 && source $ROOT/config/$1 || ( echo "ERR: No such name" && exit 1 ) || exit 1;
# (3) Read content from file
cat $BUF_IN;
# (4) Flush buffer
test $FLUSH -eq 1 && echo -ne "" > $BUF_IN;