Unexpected "(" (expecting "}")


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Unexpected "(" (expecting "}")
# 1  
Old 02-13-2019
Unexpected "(" (expecting "}")

Hi all,
I run the script runvdr from the package runvdr-extreme for many years without any problem (I'm not allowed to post links, but it should be easy to find). Now I tried to run it from within LibreElec which gives me the following error
Code:
unexpected "(" (expecting "}")

. The corresponding line contains
Code:
ADDPARAMS=()

where ADDPARAMS describes an array.
I tried to run the script with an explicit /bin/bash without any changes.
My skills in scripting are extreme limited and I don't know if it's possible to locate the error without being able to run it on LibreElec but maybe someone has the sparkling idea.
Thanks in advance
Alex
# 2  
Old 02-13-2019
Hi Alex,
Welcome to the UNIX.com forum.

When starting a new thread here, please always tell us what operating system you're using and what shell you're using. Various common utilities behave differently on various operating systems and when run by various shells. Many utilities have options that are available on some operating systems but not on others. If we don't know what environment you're using, we have to guess at what might be happening to you.

You say that you have been running runvdr for years. What has changed since the last time you ran it successfully? Did you install any new software packages, system or application updates, start using a different shell?

What exact command did you use to invoke runvdr?

Exactly what diagnostic messages did it produce when you invoked it?

When the shell tells you it was expecting a }, it usually means that sometime before it issued that complaint it had found a { and it hasn't found a match for it yet to finish what it had been told to do. With the complete diagnostic message and the contents of the script you're running, we might have a much better chance of helping you figure out what happened.

Last edited by Don Cragun; 02-13-2019 at 03:49 PM..
This User Gave Thanks to Don Cragun For This Post:
# 3  
Old 02-13-2019
Hi Don Cragun,
thanks for your answer.
Actually I told you what operating system I (want to) use: LibreElec. It's a JustEnoughOS based (I guess) on Linux from scratch.
Maybe this was misleadingly formulated.
The same script without any changes is running (for years) on the pc I'm working on. Current OS is Ubuntu Trusty. So it's not the script that changed, it's just that I want to run it on LibreElec.
LibreElec uses busybox, but bash is installed.
The script is executable so normaly I run it by invoking runvdr, but as I wrote I also tried /bin/bash /usr/bin/runvdr.
The only diagnostic message is the error message telling me that line 204 produces the error
Code:
Unexpected "(" (expecting "}")

The script itself is definitely too large to be posted here.
As the script is running on other pc's without any problems I don't think that there's a matching } missing. I found that arrays are handled different in different shells. That's why I tried /bin/bash, the shebang is correct too. So I wonder if the code can be changed so that it's more "universal". Is unset somearray the same as somearray=() ?
# 4  
Old 02-13-2019
So you said this code had been running for years and nothing had changed, but what has changed is that you're trying to run it under a different operating system. That is a HUGE difference.

What version of bash is installed on the system(s) where runvdr is working?

What version of bash is installed on busybox on LibreElec?

You said the shebang is correct... please show us the exact contents of the first line of runvdr.

Can code that is written to run with a specific version of a specific shell be rewritten to be more universal? Probably. Will changing the single line of code:
Code:
ADDPARAMS=()

in a script that is too big to post fix the problem? Almost certainly not. And, believe it or not, the shell that is attempting to run runvdr is telling you that it is looking for a } when it gives you that diagnostic message. It is saying that it gave up looking for the } and reported the error when it found the ( in the array assignment statement. The array assignment is not necessarily the problem; it is just where that shell determined that it was lost while trying to interpret that script.
# 5  
Old 02-13-2019
I've managed to find the script you are talking about from runvdr 0.5.0. I've cut it down to a 59 line script that contains the spirit of what is going on:

Code:
#!/bin/bash
RUNVDR="${0##*/}"
RUNVDRCONF=""

# Some unix commands being used:

PS="ps"
GETOPT="getopt"

which $PS        >/dev/null || { echo missing $PS... >&2 ;      exit 1 ; }
which $GETOPT    >/dev/null || { echo missing $GETOPT... >&2 ;  exit 1 ; }

function ParseCommandLine_Step1() {
    SHORTOPT="a:c:C:dD:E:g:hi:l:L:mp:P:r:s:t:u:v:Vw:"
    LONGOPT="runvdr-conf:,xserver-proxy:,pluginsetup-conf:,setupplugin-conf:,vdr:,\
        switchterminal:,maxrestarts:,restarttime:,xserver:"

    # prepare all optios for later processing
    OPTIONS=`$GETOPT -o "$SHORTOPT" --long "$LONGOPT" -n "$0" -- "$@"` || exit 1

    eval set -- "$OPTIONS"

    XSERVERPROXY=
    while true ; do case "$1" in
        -C|--runvdr-conf)  RUNVDRCONF="$2";  shift 2;;
           --xserver-proxy) XSERVERPROXY="$2"; shift 2;;
           --pluginsetup-conf)               shift 2;;
           --setupplugin-conf)               shift 2;;
           --vdr)                            shift 2;;
           --switchterminal)                 shift 2;;
           --xserver)                        shift 2;;
        --)
            shift
            break
            ;;
        *)
            echo "Internal error!" >&2
            exit 1
            ;;
    esac ; done
}

function Clean() {
    # Clean all config variables
    ADDPARAM=
    ADDPARAMS=()
    PLUGINSETUPCONF=
    SETUPPLUGINCONF=
}

#### ---------------
####   Main script
#### ---------------

# Parse command line, step 1
ParseCommandLine_Step1 "$@" || exit 1

# Clean variables
Clean

Are you getting the same error on line 46 of this script?
These 5 Users Gave Thanks to Chubler_XL For This Post:
# 6  
Old 02-14-2019
The Bash version of Libreelec is 4.3.46, busybox 1.30.0.
The bash version that's working is 4.3.11

Quote:
I've managed to find the script
Thanks for your efforts.

Quote:
Are you getting the same error on line 46 of this script?
Please give me some time, will have a look ASAP.
# 7  
Old 02-14-2019
Does your busybox version really offer bash? Mine doesn't:
Quote:
Currently defined functions:
... , ash, awk, basename, blkdiscard,
but sh (ash) is there. And sh doesn't have arrays.
So, if I run above Clear function definition (thanks Chubler_XL for providing) in busybox, I get

Code:
sh: syntax error: unexpected "(" (expecting "}")

Are you sure you posted the entire error message in post #1?
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. AIX

Apache 2.4 directory cannot display "Last modified" "Size" "Description"

Hi 2 all, i have had AIX 7.2 :/# /usr/IBMAHS/bin/apachectl -v Server version: Apache/2.4.12 (Unix) Server built: May 25 2015 04:58:27 :/#:/# /usr/IBMAHS/bin/apachectl -M Loaded Modules: core_module (static) so_module (static) http_module (static) mpm_worker_module (static) ... (3 Replies)
Discussion started by: penchev
3 Replies

2. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

3. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

4. Solaris

The slices "usr", "opt", "tmp" disappeared!!! Help please.

The system don't boot. on the screen appears following: press enter to maintenance (or type CTRL-D to continue)...I checked with format command. ... the slices "0-root","1-swap","2-backup" exist. ...the slises "3-var","6-usr" -unassigned. :( (16 Replies)
Discussion started by: wolfgang
16 Replies

5. Shell Programming and Scripting

how to use "cut" or "awk" or "sed" to remove a string

logs: "/home/abc/public_html/index.php" "/home/abc/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" how to use "cut" or "awk" or "sed" to get the following result: abc abc xyz xyz xyz (8 Replies)
Discussion started by: timmywong
8 Replies

6. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

7. Shell Programming and Scripting

cat $como_file | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g'

hi All, cat file_name | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g' Can this be done by using sed or awk alone (4 Replies)
Discussion started by: harshakusam
4 Replies

8. Shell Programming and Scripting

Syntax error: word unexpected (expecting ")")

I have a very simple script that reads in the contents of a file (_open.txt) into an array "lyrics": #!/bin/sh # read in the text lyrics=( `cat _open.txt` | tr '\n' ' ') exit 0 It gives the following error message: ./lyrics.sh: 1: Syntax error: word unexpected (expecting ")") I have... (9 Replies)
Discussion started by: figaro
9 Replies

9. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies
Login or Register to Ask a Question