Skip to content

Commit

Permalink
Add check that input source is an uncompressed text file.
Browse files Browse the repository at this point in the history
  • Loading branch information
flexibeast committed Oct 31, 2024
1 parent fffbdf1 commit bf809f8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion wgetpaste
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,10 @@ requiredarg() {
((args++))
}

notplaintext() {
die "The input source: \"$1\" is not a plain text file."
}

notreadable() {
die "The input source: \"$1\" is not readable. Please specify a readable input source."
}
Expand Down Expand Up @@ -534,7 +538,7 @@ x_cut() {
### output
usage() {
cat <<EOF
Usage: $0 [options] [file[s]]
Usage: $0 [options] [uncompressed text file[s]]
Options:
-l, --language LANG set language (defaults to "$DEFAULT_LANGUAGE")
Expand Down Expand Up @@ -1016,6 +1020,9 @@ case "$SOURCE" in
files )
if [[ ${#FILES[@]} -gt 1 ]]; then
for f in "${FILES[@]}"; do
if ! file "${f}" | grep -q 'ASCII'; then
notplaintext "${f}"
fi
[[ -r $f ]] || notreadable "$f"
if [[ $TEE ]]; then
echo "$PS1 cat $f$N$(strip_ansi "$f")$N" | tee -a "$TMPF"
Expand Down

0 comments on commit bf809f8

Please sign in to comment.