I have been doing a bash programming assignment for Uni and everything is working, except the Automark software (which is blackbox) is giving me a 0/5.. I contacted my Uni lecturer and he replied that:
"There appears to be some confusion about what "reading from standard input" means. This means you read from the keyboard of your terminal NOT from the command line.... This error is in histo (previous program). It also appears to be in histoplot. (program I'm talking about here)"
Now I have NO IDEA WHAT THIS MEANS. I have looked all over the internet, and I thought the my code is reading from standard input.
Isn't that what "While Read Line" does? My program gets data and turns it into a Histoplot that looks like this:
1 1
2 3
3 2
4 1
and turns it into this:
1 #
2 ###
3 ##
4 #
Here is my code (Sorry there's so much):
#!/bin/bash
addWordcount=0
customHash=0
customHashchoice="#"
scale=0
for i in $*
do
if [[ $i = "-c" ]]
then
addWordcount=1
elif [[ $i = "-p" ]]
then
customHash=1
elif [[ $i = "-s" ]]
then
scale=1
fi
done
for x in $*
do
if [ -f $x ] ; then
while read line
do
lineAmnt=${line% *}
hashNo=${line##* }
for ((i=0; i<hashNo; i++))
do
hashes+="#"
#hashNumber=$(expr $hashNumber - 1)
done
printf "%3s" $lineAmnt
if [[ $addWordcount -eq 1 ]]
then
printf "%5s"$hashNo
fi
printf " $hashes\n"
hashes=""
done < $x
fi
done
while read linedoes read from stdin. stdin is not always (or even usually) a keyboard, but many people conflate the two. Do not allow yourself to fall into the trap of thinking that stdin is a keyboard.