bad options(s)

Hi Folks,

I am seeing an issue in solaris, while running a script..

Script contents

#!/usr/bin/bash

echo $HOME
echo "********** RUNNING props on test ********"
. /opt/home/weblogic/.profile > /dev/null
echo "****** CURRENT BRANCH: $BRANCH *********";

. /opt/home/weblogic/.profile has set -o emacs on it..

The issue is that when i run the script as ./test.sh, it works as expected..

But when i execute the script as sh test.sh or sh -xv test.sh, it throws bad options(s) error

sh -xv test.sh
#!/usr/bin/sh

echo $HOME
+ echo /opt/home/weblogic
/opt/home/weblogic
echo "********** RUNNING props on sswc01 "
+ echo ********** RUNNING props on sswc01 *

********** RUNNING props on sswc01 *
******
. /opt/home/weblogic/.profile > /dev/null
+ . /opt/home/weblogic/.profile
+ [ -f /opt/p4/ops/deploy/.profile.weblogic ]
+ . /opt/p4/ops/deploy/.profile.weblogic
+ set -o emacs
test.sh: -o: bad option(s)

/opt/p4/ops/deploy/.profile.weblogic has `set -o emacs` command on it

Can someone pls let me know how can i get rid of this. I am letting jenkins run these commands and jenkins cannot run it as ./test.sh unfortunately..

Appreciate your help..

'set -o emacs' is pointless inside a shell script. It changes the way interactive shell prompts work, allowing you use arrow-keys and such to edit your line.

Using a different shell may allow it to work unmodified, though it's still pointless.

You may want to edit that .profile to make sure it only runs set -o emacs when $SHELL is the shell it expects.

Here is your mistake. You shell script is clearly a bash one so you should run it with

bash test.sh

or

bash -xv test.sh

but not

sh ...

Bash is not sh, especially on Solaris.

thanks bash test.sh worked like a charm.. thanks for the help