Skip to content

Commit

Permalink
Merge pull request pystardust#105 from Euro20179/stdin
Browse files Browse the repository at this point in the history
Fix: better stdin error
  • Loading branch information
pystardust authored Mar 7, 2021
2 parents 0bc7522 + 00866d9 commit 5c8109b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ytfzf
Original file line number Diff line number Diff line change
Expand Up @@ -735,10 +735,11 @@ while getopts "LhDmdfxHarltsvn:U:-:" opt; do
done
shift $((OPTIND-1))

#if stdin is given and no input (including -) is given, throw error
if [ ! -t 0 -a -z "$*" ]; then
printf "\033[31mERROR[#04]: Use - when reading from stdin\033[000m\n"
exit 1
#read stdin if given
if [ ! -t 0 -a "$*" != "-" ]; then
printf "\033[31mERROR[#04]: use - when reading from stdin\033[000m\n"
exit 1;
elif [ "$*" = "-" ]; then
printf "Reading from stdin\n"
while read line
Expand Down

0 comments on commit 5c8109b

Please sign in to comment.