我正在尝试使用 ruby shell 执行显示连接到 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 匹配之前在 shell 中运行命令并显示输出?