所以我有这个小问题。我不确定它出了什么问题,因为我非常确定我的代码是正确的。 这是代码:
#!/bin/bash
playerHP=100
echo "Hello World"
echo "HP: $playerHP"
echo "Continue? (Y/N):"
read -p $confirm
if [ "$confirm" = "y" ]
then
echo "Yes"
elif [ "$confirm" = "n" ]
then
echo "No"
else
echo "No such command"
fi
答案 0 :(得分:5)
无关:void IntervalMapEstimator::extract_relevant_points_multithread_with_localvector(std::vector<Point3D>& relevant_points ,std::vector<Point3D>& pointcloud, doubleIE cell_min_angle_sensor_rot, doubleIE cell_max_angle_sensor_rot)
{
#pragma omp parallel num_threads(5)
{
std::vector<Point3D> local_relevant_points;
#pragma omp for
for(int i = 0; i < pointcloud.size(); i++) {
// Check whether the cell is between the 2nd and 3rd quadrant (--> e.g. -170 to 170°)
if (cell_min_angle_sensor_rot < 0 && cell_max_angle_sensor_rot >= 0 && abs(cell_min_angle_sensor_rot) > M_PI/2 && abs(cell_max_angle_sensor_rot) > M_PI/2) {
// Point must be smaller than the minimum angle and bigger than the max angle (e.g. min-angle: -1.5 max-angle: 1.5 point angle bigger than 1.5 or smaller than -1.5)
if (pointcloud[i].pol_sensor_rot.phi <= cell_min_angle_sensor_rot || pointcloud[i].pol_sensor_rot.phi >= cell_max_angle_sensor_rot ) {
local_relevant_points.push_back(pointcloud[i]);
}
} else {
if (pointcloud[i].pol_sensor_rot.phi >= cell_min_angle_sensor_rot && pointcloud[i].pol_sensor_rot.phi <= cell_max_angle_sensor_rot ) {
local_relevant_points.push_back(pointcloud[i]);
}
}
}
#pragma omp critical
{
if(!local_relevant_points.empty())
relevant_points.insert (relevant_points.end (),local_relevant_points.begin (),local_relevant_points.end ());
}
}
}
需要read
之后的提示。将之前的-p
混合到其中,然后在其中删除变量名称中的echo
。
$
错误消息令人困惑。你没有在脚本中有MSWin行结束吗?
答案 1 :(得分:1)
您好我已修改您的脚本以下使用它。对我来说工作正常
#!/bin/bash
playerHP=100
echo "Hello World"
echo "HP: $playerHP"
read -p "Continue? (Y/N): " confirm
echo $confirm
if [ "$confirm" = "y" ]
then
echo "Yes"
elif [ "$confirm" = "n" ]
then
echo "No"
else
echo "No such command"
fi