test.sh:
#!/bin/bash
echo "helloworld"
I set the file mode to 755. when I try to run the script by typing "./test.sh", I get this:
helloworld
./test.sh: line 2: /root: is a directory
what's going on???
I'd look for funny business in error/signal handlers and or the PROMPT_COMMAND
So,
echo $PS1
echo $PROMPT_COMMAND
trap
would be in order.
Another approach is to make bash run restricted (which disables a whole slew of options)
#!/bin/bash -r
While the latter may resolve the strange behaviour, it wouldn't explain waht happened
I got this error when I accidentally put a ~ on the last line of my script while aiming for the escape key in vim. Because vim uses tildes to fill lines outside the file the mistake was nearly invisible. Removing the line containing the tilde got me rid of the
/root: Is a directory
error.
test.shas you are executing?cat ./test.sh;./test.shwould be interesting to see.