Bash 我的shell脚本有什么问题;如果情况如何?

Bash 我的shell脚本有什么问题;如果情况如何?,bash,shell,Bash,Shell,我有一个启动计划的第二个列表,我希望在工作时启动这些计划。因此,我在Ubuntu上运行的系统启动时添加了这个shell脚本 echo "Do you want to start the start up applications[Y/n]?" while read inputline do what="$inputline" break done if [ "$what" == "Y" -o "$what" == "y" ] then . ~/bin/webstorm.sh

我有一个启动计划的第二个列表,我希望在工作时启动这些计划。因此,我在Ubuntu上运行的系统启动时添加了这个shell脚本

echo "Do you want to start the start up applications[Y/n]?"

while read inputline
do
    what="$inputline"
    break
done

if [ "$what" == "Y" -o "$what" == "y" ]
then
. ~/bin/webstorm.sh &
workrave &
firefox &
. ~/bin/AptanaStudio3
fi
我一直收到这样一个错误,它总是说类似于
[:Y:unexpected operator
,并且从不启动程序

免责声明:我不知道如何编写shell脚本。尝试更改:

if [ "$what" == "Y" -o "$what" == "y" ]


你的shebang行是什么?
!/bin/bash
!/bin/sh

如果您打算使用bash作为脚本解释器,请不要忘记shebang行


(您的代码至少在我的系统上使用bash…)

=
与双
=
?至少值得一试……与
读什么相比,我不理解你的读循环;什么时候你的循环行为会有所不同?@Jonathan Leffler:我猜目的是给用户一个机会在提示下取消。当然,只要
,而不是
>循环就足够了。对于
sh
您也需要将
~
更改为
$HOME
。嗯……我没有检查到这一点。因为条件语句本身失败。或者更好的是
case$what in[Yy]);;*)退出0;;esac
if [[ "$what" == "Y" ]] || [[ "$what" == "y" ]]