test.sh:
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:
我将文件模式设置为755.当我尝试通过键入“./test.sh”来运行脚本时,我得到了这个:
helloworld
./test.sh: line 2: /root: is a directory
what's going on???
这是怎么回事???
3 个解决方案
#1
1
Put an exit and see
放一个出口看看
#!/bin/bash
echo "helloworld"
exit
#2
1
I'd look for funny business in error/signal handlers and or the PROMPT_COMMAND
我会在错误/信号处理程序和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)
另一种方法是限制bash运行(禁用一大堆选项)
#!/bin/bash -r
While the latter may resolve the strange behaviour, it wouldn't explain waht happened
虽然后者可以解决这种奇怪的行为,但它无法解释发生的事情
#3
0
I guess edited from Windows/reused a Windows-file with an \r
inside, which you moved around with inserting exit
?
我想从Windows编辑/重用一个带有\ r里面的Windows文件,你在插入退出时移动了吗?
#1
1
Put an exit and see
放一个出口看看
#!/bin/bash
echo "helloworld"
exit
#2
1
I'd look for funny business in error/signal handlers and or the PROMPT_COMMAND
我会在错误/信号处理程序和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)
另一种方法是限制bash运行(禁用一大堆选项)
#!/bin/bash -r
While the latter may resolve the strange behaviour, it wouldn't explain waht happened
虽然后者可以解决这种奇怪的行为,但它无法解释发生的事情
#3
0
I guess edited from Windows/reused a Windows-file with an \r
inside, which you moved around with inserting exit
?
我想从Windows编辑/重用一个带有\ r里面的Windows文件,你在插入退出时移动了吗?