bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Unknown error when running a simple bash script]


From: Greg Wooledge
Subject: Re: [Unknown error when running a simple bash script]
Date: Mon, 4 Jul 2022 13:16:26 -0400

On Mon, Jul 04, 2022 at 06:15:27PM +0200, Alex fxmbsw7 Ratchev wrote:
> On Mon, Jul 4, 2022, 18:07 <avni@avni.laptop.example.com> wrote:
> > When I am running the script, it says "[[: not found."

You're running the script with sh, not with bash.

If you are typing "sh myscript", that immediately identifies the source
of the problem.  You're literally telling it to run with "sh" as its
interpreter.  Replace the "sh" with "bash".

Ideally, a script will be installed into a directory in $PATH, and then
invoked with its filename.  When that happens, the operating system should
read the first few bytes of the script (program) to see how to run it.
If the first two bytes are #! then the characters after that identify
the interpreter that should be used.  That's why a bash script should
begin with #!/bin/bash instead of #!/bin/sh .

> you sure its bash u run ? echo $SHELL and see

The $SHELL variable will not help here.  That doesn't tell you what
shell is in use.  In only tells you what shell is defined for your user
account in /etc/passwd.

unicorn:~$ cat foo
echo "$SHELL"
unicorn:~$ bash foo
/bin/bash
unicorn:~$ dash foo
/bin/bash
unicorn:~$ zsh foo
/bin/bash



reply via email to

[Prev in Thread] Current Thread [Next in Thread]