Home > Enterprise >  Why I am getting error unbound variable cygwin bash error
Why I am getting error unbound variable cygwin bash error

Time:11-05

Following is the my script ( snippet )

#!/bin/bash

set -o errexit
set -o nounset
set -o xtrace
set -o pipefail

ARGUMENT=$1

I am trying to run with cygwin bash and Getting following error.

C:\cygwin64\bin\bash.exe -l -c /cygdrive/c/test.sh ARGUMENT1

Getting following error

  set -o pipefail
/cygdrive/c/test.sh: line 8: $1: unbound variable

CodePudding user response:

You're not passing an argument to test.sh, since the argument is not included in the -c option value that you're passing to bash. Just add quotes to fix this:

C:\cygwin64\bin\bash.exe -l -c "/cygdrive/c/test.sh ARGUMENT1"
  • Related