1

As far as I understand, to make kernel execve a non-ELF file, the file must be a script started with a she-bang #!, but I have a script run successfully without it, why does this happen?

xtricman⚓ArchVirtual⏺️~🤐ls a.sh -l -r-xr-xr-x 1 xtricman users 23 9月 26 18:45 a.sh xtricman⚓ArchVirtual⏺️~🤐cat a.sh echo "FDHDSFHGFKJJHGO" xtricman⚓ArchVirtual⏺️~🤐./a.sh FDHDSFHGFKJJHGO 

This a.sh script doesn't contain a she-bang, so how does it run?

1
  • Your current shell interprets it. Commented Sep 27, 2018 at 1:31

1 Answer 1

4

If the file does not start with a "shebang" line, most shells will attempt to execute the lines in the file themselves.

2
  • Can I disable this behavior of bash? Commented Sep 27, 2018 at 2:07
  • 1
    The shell will only do this on files marked "executable". If you don't want to execute the file then remove the x flag (chmod a-x a.sh) Commented Sep 27, 2018 at 2:41

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.