Illegal Option -n OR too many arguments

I’m on Linux Mint 18.1, and have a nemo action calling a bash script to autounsync a folder using Right-Click>AutoUnsync.
For now this is just a test folder to see how it works. So far, it’s not- and I don’t know what I’m doing wrong here.

/home/matt/.local/share/nemo/scripts/autounsync.sh
> agentdir="$HOME/.odrive-agent/bin"
> export agentdir
> targetdir=$1
> python “$agentdir/odrive.py” refresh “$targetdir”
> echo Waiting for odrive to start syncing $targetdir …
> while [ $(python “$agentdir/odrive.py” syncstate “$targetdir” | head -n 1) == ‘Synced’ ]; do
> sleep 5
> done
> echo odrive is syncing changes in $targetdir …
> while [ $(python “$agentdir/odrive.py” syncstate “$targetdir” | head -n 1) != ‘Synced’ ]; do
> find “$targetdir” ! -name ‘.cloud’ -type file -exec bash -c 'thepath="$1"; if [[ $(python “$agentdir/odrive.py” syncstate “$thepath” | head -n 1) == Synced ]]; then echo “$thepath” is synced! Unsyncing…; python “$agentdir/odrive.py” unsync “$thepath” ; fi ’ _ {} ;
> sleep 5
> done
> echo Sync complete! Unsyncing $targetdir …
> python “$agentdir/odrive.py” unsync “$targetdir”
> read -n 1 -s -r -p “Press any key to continue”
> bash

/usr/share/nemo/actions

[Nemo Action]
Active=true
Name=AutoUnsync
Quote=double
Exec=gnome-terminal -e "/home/matt/.local/share/nemo/scripts/autounsync.sh %F"
Icon-Name=googlemusicframe
Selection=notnone
Extensions=dir;
EscapeSpaces=false

Terminal Output for this is:

Not Synced
IMG_20170623_092128-01.jpg
odrive-recursivesync.nemo_action
dotnetfx45_full_x86_x64.exe
winetricks-master.zip
ec2-54-68-1-54.us-west-2.compute.amazonaws.com.rdp
Shyra KEHE (1).xlsx
Eshcert.der
advanced-systemcare-setup.exe
Ninite NET 47 Installer.exe
s3browser-6-5-9.exe
odrive-unsync.nemo_action
Shyra KEHE.xlsx
CloudBerryBackup_v5.6.2.25ULTIMATE.exe
Troyers.xlsx
Sheetgo-15-Essential-Formulas-to-Become-a-Data-Analyst-in-Google-Sheets-v2.pdf
odrive-utilities-master.zip
certificate.crt
rclone-v1.36-linux-amd64.zip
USB Flash Drive - serial.zip
odrive-sync.nemo_action
winetricks-master
Waiting for odrive to start syncing /home/matt/odrive/mattzab@mattzab/testautous ...
/home/matt/.local/share/nemo/scripts/autounsync.sh: 6: [: Not: unexpected operator
odrive is syncing changes in /home/matt/odrive/mattzab@mattzab/testautous ...
/home/matt/.local/share/nemo/scripts/autounsync.sh: 10: [: Not: unexpected operator
Sync complete! Unsyncing /home/matt/odrive/mattzab@mattzab/testautous ...
Some files are not in sync. If you want to permanently delete these files and unsync, use the --force flag. testautous is not in sync.
/home/matt/.local/share/nemo/scripts/autounsync.sh: 16: read: Illegal option -n

When I add

#!/bin/bash

to the bash script, I get this terminal output:

Not Synced
IMG_20170623_092128-01.jpg
odrive-recursivesync.nemo_action
dotnetfx45_full_x86_x64.exe
winetricks-master.zip
ec2-54-68-1-54.us-west-2.compute.amazonaws.com.rdp
Shyra KEHE (1).xlsx
Eshcert.der
advanced-systemcare-setup.exe
Ninite NET 47 Installer.exe
s3browser-6-5-9.exe
odrive-unsync.nemo_action
Shyra KEHE.xlsx
CloudBerryBackup_v5.6.2.25ULTIMATE.exe
Troyers.xlsx
Sheetgo-15-Essential-Formulas-to-Become-a-Data-Analyst-in-Google-Sheets-v2.pdf
odrive-utilities-master.zip
certificate.crt
rclone-v1.36-linux-amd64.zip
USB Flash Drive - serial.zip
odrive-sync.nemo_action
winetricks-master
Waiting for odrive to start syncing /home/matt/odrive/mattzab@mattzab/testautous …
/home/matt/.local/share/nemo/scripts/autounsync.sh: line 7: [: too many arguments
odrive is syncing changes in /home/matt/odrive/mattzab@mattzab/testautous …
/home/matt/.local/share/nemo/scripts/autounsync.sh: line 11: [: too many arguments
Sync complete! Unsyncing /home/matt/odrive/mattzab@mattzab/testautous …
Some files are not in sync. If you want to permanently delete these files and unsync, use the --force flag. testautous is not in sync.

Lines 7 & 11 are the lines that start with 'while’
Any thoughts? I sure appreciate the support here.

Hi @mattzab,
I think the issue is quotes. It looks like you got some of this from a script I posted elsewhere, although I’m not sure how I had it working…heh. I corrected that one.

In this case, include the #!/bin/bash and then add double quotes around the strings being compared in the while and if statements. For example:
while [ "$(python "$agentdir/odrive.py" syncstate "$targetdir" | head -n 1)" != "Synced" ]; do