Need another pair of eyes (BASH script throwing a "s-e-n-u-t" error)
"s-e-n-u-t"? syntax error near unexpected token.
(I wasn't sure it rated acronym status, but setting off the first letter of each word with hyphens seemed appropriate.) Anyway, here's the script: Code:
#!/bin/bash Quote:
Code:
while read 'line'; And as a side question: is there any way I can cut down on the number of if/fi's I have in this script. I'm not too fluent with case loops, but those would seem to be appropriate here. Thanks for looking at this OP. BZT |
Looks like you're missing a "fi" on line 32. :) That should fix the syntax error.
|
1. you've skipped a fi
Code:
if [ -n "$s" ] && [ -n "$t" ] && [ -z "$v" ]; then http://rute.2038bug.com/index.html.gz http://tldp.org/LDP/Bash-Beginners-G...tml/index.html http://www.tldp.org/LDP/abs/html/ 2. If you want to empty a file Code:
>$survey-captions.txt 3. a good cmd to use for debugging is Code:
set -xv |
Many thanks to both of you...
I thought all my "ifs" were paired with "fi's" but evidently not.
Thanks for the links to tips on case loops. I haven't had all that much luck with 'elif', though maybe I wasn't using it quite right, either. I'll read up on both asap. BZT |
Try this page http://tldp.org/LDP/Bash-Beginners-G...ect_07_02.html.
Also recommend [[ ]] http://tldp.org/LDP/abs/html/testcon...ml#DBLBRACKETS |
I would also question the use of quotes around the read variable. Not sure if it causes any issues but there is no value to it.
|
Some comments on your script, starting with a few unnecessary patterns:
Code:
SAVEIFS=$IFS 2) Bash has a special $'' quoting style (usually called ansi-c style quotes, see the QUOTING section of the man page) for inserting non-printing characters. You can use this instead of echo -e: Code:
IFS=$'\n\b' 3) You don't need to echo a parameter expansion. Just set the new variable directly: Code:
survey=${PWD##*/} Code:
let d++ 5) Always remember to quote your variable expansions! Remember the links I gave you in your last thread? 6) You probably want to use a single if..elif...else statement, rather than a series of separate ifs. 7) Also consider using bash's new [[..]] test instead of [..]. It's safer and more powerful. You could combine all your tests into one command, for one thing. Code:
if [[ -n "$s" && -z "$t" && -z "$v" ]]; then By the way, assuming I understand it correctly, I believe you can replace the whole thing with this: Code:
z=${v:-${t:-$s}} parameter substitution Finally, I just posted a comment in that thread with some scripting suggestions. You may want to take a look at it. |
All times are GMT -5. The time now is 04:18 PM. |