-1

I'm looking at a bash script with this:

PARAMS="%1;$1;$2;$3;$4;$5;$6;$7;$8;$9"

As I understand it, the parameters that are passed in on script execution will be added to this list.

When I run this:

runscript.sh CONFIG 2>&1

I see this error:

line 76: [[%1;CONFIG;;;;;;;;: command not found

where line 76 contains this:

if [[$PARAMS =~ "CONFIG" ]];

What does the %1 mean and how should I run the script to get it to work?

runnerpaul
  • 5,942
  • 8
  • 49
  • 118
  • 2
    You need a space after `[[`: `if [[ $PARAMS =~ "CONFIG" ]];` – Poshi Feb 28 '19 at 19:03
  • 1
    BTW, `%1` was introduced by you... you should know its meaning, not us! – Poshi Feb 28 '19 at 19:03
  • 1
    This is a common error: `[[` is actually a *command*, not mere syntax. You need whitespace to separate the command from the arguments. The error message is bash complaining that it can't find the command named `"[[$PARAMS"` – glenn jackman Feb 28 '19 at 19:04
  • Sorry, I made a false claim. I was asked to get the script working. The author isn't available and my bash knowledge is very limited. – runnerpaul Feb 28 '19 at 19:05
  • [Shellcheck](https://www.shellcheck.net/) can find this bug, and many others. – pjh Mar 01 '19 at 20:02

1 Answers1

0

I didn't have a space after the [[. Once added the script worked.

runnerpaul
  • 5,942
  • 8
  • 49
  • 118