0

Trying to implement this code(https://github.com/kentonl/e2e-coref) But while running setup_all.sh getting bad substitution error.

#!/bin/bash

# Download pretrained embeddings.
#curl -O http://downloads.cs.stanford.edu/nlp/data/glove.840B.300d.zip
#unzip glove.840B.300d.zip
#rm glove.840B.300d.zip

# Build custom kernels.
TF_CFLAGS=$(python -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_compile_flags()))')
TF_LFLAGS=$(python -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_link_flags()))')
echo $TF_CFLAGS
echo $TF_LFLAGS

# Linux (pip)
g++ -std=c++11 -shared coref_kernels.cc -o coref_kernels.so -fPIC ${TF_CFLAGS[@]} ${TF_LFLAGS[@]} -O2 -D_GLIBCXX_USE_CXX11_ABI=0

# Linux (build from source)
#g++ -std=c++11 -shared coref_kernels.cc -o coref_kernels.so -fPIC ${TF_CFLAGS[@]} ${TF_LFLAGS[@]} -O2

# Mac
#g++ -std=c++11 -shared coref_kernels.cc -o coref_kernels.so -I -fPIC ${TF_CFLAGS[@]} ${TF_LFLAGS[@]} -O2 -D_GLIBCXX_USE_CXX11_ABI=0 -undefined dynamic_lookup

Getting bad substitution error in line 15. Any help would be appreciated:)

melpomene
  • 84,125
  • 8
  • 85
  • 148
Lucifer
  • 67
  • 2
  • 9
  • What's the exact error message? And how are you running this code? – melpomene Jun 15 '19 at 11:27
  • @EdMorton no quoting doesnt helped. But removing [@] helped – Lucifer Jun 15 '19 at 11:41
  • 1
    Why did you remove the parens from the variable assignment? The original script had `TF_CFLAGS=( $( ... ) )` and `TF_LFLAGS=( $( ... ) )`, which works fine. – melpomene Jun 15 '19 at 11:42
  • The code is actually comparatively fine (the `[@]` is superfluous but not harmful). The problem is instead that you're running the script with `sh` instead of `bash`. – that other guy Jun 15 '19 at 16:34

1 Answers1

0

[@] is used to expand an array to all its elements. Your variables are not arrays.

Also, Use More Quotes™.

l0b0
  • 55,365
  • 30
  • 138
  • 223
  • Funnily enough, the [original script](https://github.com/kentonl/e2e-coref/blob/875d55eb0a1aae80f0379057b39636e5bfba6f3a/setup_all.sh) uses arrays. I wonder why OP changed it. – melpomene Jun 15 '19 at 11:37