Ios Fastlane注释输出字符串中的引号

Ios Fastlane注释输出字符串中的引号,ios,ruby,fastlane,fastlane-match,Ios,Ruby,Fastlane,Fastlane Match,我正在尝试使用ruby shell execute显示连接到mac的iOS设备 system_profiler SPUSBDataType | grep -A 11 -w "iPad\|iPhone\|iPad" 在终端中,输出良好 如何正确地转义字符并在ruby控制台中运行此操作 但是当使用Fastfile的通道添加相同的内容时,请注意使用“\”的转义引号。我得到一个非零出口的错误 desc "Register a new device" lane :register_new_devic

我正在尝试使用ruby shell execute显示连接到mac的iOS设备

system_profiler SPUSBDataType | grep -A 11 -w "iPad\|iPhone\|iPad"
在终端中,输出良好

如何正确地转义字符并在ruby控制台中运行此操作

但是当使用Fastfile的通道添加相同的内容时,请注意使用“\”的转义引号。我得到一个非零出口的错误

desc "Register a new device"
  lane :register_new_device do
      UI.message("Detected device")
      sh("system_profiler SPUSBDataType | grep -A 11 -w \"iPad\|iPhone\|iPad\"")
      device_name = prompt(text: "Enter the device name: ")
      device_udid = prompt(text: "Enter the device UDID: ")
      device_hash = {}
      device_hash[device_name] = device_udid
      register_devices(devices: device_hash)
      new_devices
  end
错误:

[08:23:56]: Exit status of command 'system_profiler SPUSBDataType | grep -A 11 -w "iPad|iPhone|iPad"' was 1 instead of 0.
2018-12-07 08:23:55.602 system_profiler[21056:476660] SPUSBDevice: IOCreatePlugInInterfaceForService failed 0xe00002be
预期产出:

2018-12-07 08:27:52.170 system_profiler[21266:479375] SPUSBDevice: IOCreatePlugInInterfaceForService failed xx
        iPhone:

          Product ID: xx
          Vendor ID: xx (Apple Inc.)
          Version: xx
          Serial Number: xxx
          Speed: Up to 480 Mb/sec
          Manufacturer: Apple Inc.
          Location ID: xx / 3
          Current Available (mA): xx
          Current Required (mA): xx
          Extra Operating Current (mA): xx

在用户将设备添加到Fastlane match之前,如何在shell中运行命令并显示输出?

您运行的命令似乎总是返回状态代码
1
,而不是
0
,即使直接运行它也是如此。完成后运行
echo$?
进行检查

如果情况确实如此,并且是预期的或想要的,您必须让fastlane的
sh
接受这一点。您可以通过给
sh
一个命令来执行,如果状态为1,则将执行该命令。它实际上不需要做任何事情,所以空方法应该可以


(这背后的内部逻辑和代码是-注意错误消息是如何以
UI.shell\u error!
输出的,它在没有回调时停止执行,但是
UI.error
在回调出现时只输出一条红色错误消息。)

该shell命令返回什么?返回非零出口究竟是什么?由
sh()
操作执行的命令?它应该只在控制台上打印一些内容,更正这行导致问题的原因->sh(“system_profiler SPUSBDataType | grep-A 11-w \“iPad \ | iPhone \ | iPad\”)能否将运行此通道的输出添加到问题中?错误消息添加到问题中