Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add check that input source is an uncompressed text file. #56

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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