0

screenshot with error message

I do not understand what I am doing wrong. Any help would be appreciated.

Thank you!

#!/bin/bash
SEATS=$1
seats_remaining=$SEATS
for ((i = $SEATS; i >=1; i--));
do
    echo "$i will take a seat"
    seats_remaining="$(($seats_remaining-1))"
    ./Lab4 $seats_remaining $i &
done
trap "exit" INT TERM ERR
trap "kill 0" EXIT`enter code here`
wait
Charles Duffy
  • 280,126
  • 43
  • 390
  • 441
Maria
  • 1
  • "Snippets" are only for code that can run in a browser. Just use the `{}` button for languages that aren't javascript/html/etc. – Charles Duffy Jul 02 '20 at 20:55
  • That said, the error message in your screenshot -- and in the future, **don't** post screenshots here, copy-and-paste errors as text -- means that your script has CRLF characters; that is, it's saved with DOS newlines, not as a UNIX script. – Charles Duffy Jul 02 '20 at 20:56
  • ...the giveaway for that is `$'\r'` is how bash describes a CR -- a carriage return. DOS files separate lines with CRLF sequences (`$'\r\n'`), whereas UNIX text files only use LFs (`$'\n'`) and shouldn't have any CRs in them at all. – Charles Duffy Jul 02 '20 at 20:57
  • BTW, you might run your code through http://shellcheck.net/ and fix up the warnings it throws. – Charles Duffy Jul 02 '20 at 20:58

0 Answers0