bash 参数解析

发布时间 2023-08-31 13:59:42作者: feipeng8848
while [[ $# -gt 0 ]]; do
  case $1 in
    -h)
      printUsage;
      exit 1;
      ;;
    --help)
      printUsage;
      exit 1;
      ;;
    --qmake)
      qmake_tool="$2"
      //shift 2 表示跳过两个参数
      shift 2
      ;;
    --uipro)
      ui_profile="$2"
      shift 2
      ;;
    --gatewaypro)
      gateway_profile="$2"
      shift 2
      ;;
    --controlpro)
      control_profile="$2"
      shift 2
      ;;
    --cloudserverpro)
      cloudserver_profile="$2"
      shift 2
      ;;
    --deploypath)
      deploy_path="$2"
      shift 2
      ;;
    *)
      echo "Invalid option: $1"
      exit 1
      ;;
  esac
done